Skip to content

Commit 4335470

Browse files
committed
chore: add cli example
1 parent 6c3acd7 commit 4335470

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

examples/cli.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use css_module_lexer::{collect_dependencies, Mode};
2+
3+
fn main() {
4+
let Some(path) = std::env::args().nth(1) else {
5+
eprintln!("USAGE: cli <path>");
6+
return;
7+
};
8+
let Ok(input) = std::fs::read_to_string(&path) else {
9+
eprintln!("Failed to read file: {}", path);
10+
return;
11+
};
12+
let (dependencies, warnings) = collect_dependencies(&input, Mode::Css);
13+
if dependencies.is_empty() {
14+
println!("No dependencies found");
15+
} else {
16+
println!("Dependencies:");
17+
for dependency in dependencies {
18+
println!("{:?}", dependency);
19+
}
20+
}
21+
if warnings.is_empty() {
22+
println!("No warnings found");
23+
} else {
24+
println!("Warnings:");
25+
for warning in warnings {
26+
println!("{:?}", warning);
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)