We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 2a29b55 + 849b07f commit fac4245Copy full SHA for fac4245
1 file changed
crates/codebook/src/main.rs
@@ -17,9 +17,20 @@ fn main() {
17
.windows(2)
18
.find(|w| w[0] == "--lang")
19
.map(|w| w[1].as_str());
20
- let file_arg = args.iter().find(|a| {
21
- *a != "--ast" && *a != "--lang" && !a.starts_with("--") && !a.contains("codebook")
22
- });
+ // Skip argv[0] and flag values: the file is the first positional arg.
+ let mut file_arg = None;
+ let mut iter = args.iter().skip(1);
23
+ while let Some(arg) = iter.next() {
24
+ if arg == "--lang" {
25
+ iter.next();
26
+ continue;
27
+ }
28
+ if arg.starts_with("--") {
29
30
31
+ file_arg = Some(arg);
32
+ break;
33
34
match file_arg {
35
Some(path) => dump_ast(path, lang_override),
36
None => eprintln!("Usage: codebook --ast <file> [--lang <language>]"),
0 commit comments