Drop only the first occurrence of fmt while preparing CLI arguments

This commit is contained in:
Ivan Veselov 2019-05-21 16:33:51 +01:00
parent 32fbe75a4c
commit a7afdeb9b8

View File

@ -62,7 +62,16 @@ const FAILURE: i32 = 1;
fn execute() -> i32 {
// Drop extra `fmt` argument provided by `cargo`.
let args = env::args().filter(|x| x != "fmt");
let mut found_fmt = false;
let args = env::args().filter(|x| {
if found_fmt {
true
} else {
found_fmt = x == "fmt";
x != "fmt"
}
});
let opts = Opts::from_iter(args);
let verbosity = match (opts.verbose, opts.quiet) {