Skip to content

Commit

Permalink
chore: add cli example
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Nov 29, 2024
1 parent 6c3acd7 commit 4335470
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions examples/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use css_module_lexer::{collect_dependencies, Mode};

fn main() {
let Some(path) = std::env::args().nth(1) else {
eprintln!("USAGE: cli <path>");
return;
};
let Ok(input) = std::fs::read_to_string(&path) else {
eprintln!("Failed to read file: {}", path);
return;
};
let (dependencies, warnings) = collect_dependencies(&input, Mode::Css);
if dependencies.is_empty() {
println!("No dependencies found");
} else {
println!("Dependencies:");
for dependency in dependencies {
println!("{:?}", dependency);
}
}
if warnings.is_empty() {
println!("No warnings found");
} else {
println!("Warnings:");
for warning in warnings {
println!("{:?}", warning);
}
}
}

0 comments on commit 4335470

Please sign in to comment.