fix(help): Clarify install's positional

- That a version is accepted
- That you are selecting from the source a package which led to part of
  the confusion in #4830

I wonder if we should rename our `CRATE` value names to `PKG`/`PACKAGE`
This commit is contained in:
Ed Page 2023-10-17 15:30:39 -05:00
parent 99f917a67e
commit 5f0596941f
3 changed files with 9 additions and 6 deletions

View File

@ -18,7 +18,8 @@ pub fn cli() -> Command {
.about("Install a Rust binary. Default location is $HOME/.cargo/bin")
.arg(
Arg::new("crate")
.value_name("CRATE")
.value_name("CRATE[@<VER>]")
.help("Select the package from the given source")
.value_parser(parse_crate)
.num_args(0..),
)

View File

@ -1,9 +1,9 @@
Install a Rust binary. Default location is $HOME/.cargo/bin
Usage: cargo[EXE] install [OPTIONS] [CRATE]...
Usage: cargo[EXE] install [OPTIONS] [CRATE[@<VER>]]...
Arguments:
[CRATE]...
[CRATE[@<VER>]]... Select the package from the given source
Options:
--version <VERSION> Specify a version to install

View File

@ -1614,7 +1614,7 @@ fn inline_version_without_name() {
cargo_process("install @0.1.1")
.with_status(1)
.with_stderr(
"error: invalid value '@0.1.1' for '[CRATE]...': missing crate name before '@'
"error: invalid value '@0.1.1' for '[CRATE[@<VER>]]...': missing crate name before '@'
For more information, try '--help'.
",
@ -1844,7 +1844,9 @@ fn install_empty_argument() {
cargo_process("install")
.arg("")
.with_status(1)
.with_stderr_contains("[ERROR] invalid value '' for '[CRATE]...': crate name is empty")
.with_stderr_contains(
"[ERROR] invalid value '' for '[CRATE[@<VER>]]...': crate name is empty",
)
.run();
}
@ -2455,7 +2457,7 @@ error: unexpected argument '--release' found
tip: `--release` is the default for `cargo install`; instead `--debug` is supported
Usage: cargo[EXE] install [OPTIONS] [CRATE]...
Usage: cargo[EXE] install [OPTIONS] [CRATE[@<VER>]]...
For more information, try '--help'.
",