Skip to content

Commit

Permalink
fix(help): Clarify install's positional
Browse files Browse the repository at this point in the history
- 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`
  • Loading branch information
epage committed Oct 17, 2023
1 parent 99f917a commit 5f05969
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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..),
)
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_install/help/stdout.log
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
",
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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'.
",
Expand Down

0 comments on commit 5f05969

Please sign in to comment.