Skip to content

Commit a7afdeb

Browse files
committed
Drop only the first occurrence of fmt while preparing CLI arguments
1 parent 32fbe75 commit a7afdeb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cargo-fmt/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,16 @@ const FAILURE: i32 = 1;
6262

6363
fn execute() -> i32 {
6464
// Drop extra `fmt` argument provided by `cargo`.
65-
let args = env::args().filter(|x| x != "fmt");
65+
let mut found_fmt = false;
66+
let args = env::args().filter(|x| {
67+
if found_fmt {
68+
true
69+
} else {
70+
found_fmt = x == "fmt";
71+
x != "fmt"
72+
}
73+
});
74+
6675
let opts = Opts::from_iter(args);
6776

6877
let verbosity = match (opts.verbose, opts.quiet) {

0 commit comments

Comments
 (0)