Skip to content

Commit 1252c54

Browse files
authored
fix(run): Help teach about argument escaping (#16225)
### What does this PR try to resolve? It is not obvious that how to escape arguments to be forwarded literally to an underlying program, like `--help`. `cargo test` has a message: ``` Run `cargo test -- --help` for test binary options. ``` Mirroring that exactly in `cargo run` isn't appropriate because we'd be saying there is `--help` when there might not be. Instead, I took inspiration from clap's error message: ```console $ cargo test --gfdfgdf error: unexpected argument '--gfdfgdf' found tip: to pass '--gfdfgdf' as a value, use '-- --gfdfgdf' Usage: cargo test [OPTIONS] [TESTNAME] [-- [ARGS]...] For more information, try '--help'. ``` I checked `cargo rustc` and `cargo rustdoc` to see if they could be helped like this but they will return errors about needing to specify the specific binary, so they are a little more complicated. Fixes #9707 ### How to test and review this PR?
2 parents 445fe4a + 555f91a commit 1252c54

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/bin/cargo/commands/run.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ pub fn cli() -> Command {
4343
.arg_unit_graph()
4444
.arg_timings()
4545
.after_help(color_print::cstr!(
46-
"Run `<bright-cyan,bold>cargo help run</>` for more detailed information.\n"
46+
"Run `<bright-cyan,bold>cargo help run</>` for more detailed information.\n\
47+
To pass `--help` to the specified binary, use `<bright-cyan,bold>-- --help</>`.\n",
4748
))
4849
}
4950

tests/testsuite/cargo_run/help/stdout.term.svg

Lines changed: 5 additions & 3 deletions
Loading

0 commit comments

Comments
 (0)