aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parseopts.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/parseopts.rs b/src/parseopts.rs
index ee05199..a49d02c 100644
--- a/src/parseopts.rs
+++ b/src/parseopts.rs
@@ -164,6 +164,8 @@ pub fn parseopts() -> Opts {
let mut it = std::env::args();
let progname = it.next().expect("TG1");
+ let mut pos_arg = 0;
+
while let Some(mut arg) = it.next() {
if arg.starts_with("--") {
arg.remove(0);
@@ -197,11 +199,21 @@ pub fn parseopts() -> Opts {
}
}
}
+ } else {
+ match pos_arg {
+ 0 => {
+ opts.in_file = Some(arg);
+ },
+ _ => {
+ println!("No positional argument expected at position {} (\"{}\")", pos_arg, arg);
+ parseopts_panic!(progname);
+ }
+ }
+ pos_arg += 1;
}
}
- opts.in_file = it.next();
return opts;
}