Skip to content

Commit ace0337

Browse files
committed
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`
1 parent f715879 commit ace0337

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/bin/cargo/commands/install.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ pub fn cli() -> Command {
1818
.about("Install a Rust binary. Default location is $HOME/.cargo/bin")
1919
.arg(
2020
Arg::new("crate")
21-
.value_name("CRATE")
21+
.value_name("CRATE[@<VER>]")
22+
.help("Select the package from the given source")
2223
.value_parser(parse_crate)
2324
.num_args(0..),
2425
)

tests/testsuite/cargo_install/help/stdout.log

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Install a Rust binary. Default location is $HOME/.cargo/bin
22

3-
Usage: cargo install [OPTIONS] [CRATE]...
3+
Usage: cargo install [OPTIONS] [CRATE[@<VER>]]...
44

55
Arguments:
6-
[CRATE]...
6+
[CRATE[@<VER>]]... Select the package from the given source
77

88
Options:
99
--version <VERSION> Specify a version to install

tests/testsuite/install.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ fn inline_version_without_name() {
16141614
cargo_process("install @0.1.1")
16151615
.with_status(1)
16161616
.with_stderr(
1617-
"error: invalid value '@0.1.1' for '[CRATE]...': missing crate name before '@'
1617+
"error: invalid value '@0.1.1' for '[CRATE[@<VER>]]...': missing crate name before '@'
16181618
16191619
For more information, try '--help'.
16201620
",
@@ -1844,7 +1844,9 @@ fn install_empty_argument() {
18441844
cargo_process("install")
18451845
.arg("")
18461846
.with_status(1)
1847-
.with_stderr_contains("[ERROR] invalid value '' for '[CRATE]...': crate name is empty")
1847+
.with_stderr_contains(
1848+
"[ERROR] invalid value '' for '[CRATE[@<VER>]]...': crate name is empty",
1849+
)
18481850
.run();
18491851
}
18501852

@@ -2455,7 +2457,7 @@ error: unexpected argument '--release' found
24552457
24562458
tip: `--release` is the default for `cargo install`; instead `--debug` is supported
24572459
2458-
Usage: cargo[EXE] install [OPTIONS] [CRATE]...
2460+
Usage: cargo[EXE] install [OPTIONS] [CRATE[@<VER>]]...
24592461
24602462
For more information, try '--help'.
24612463
",

0 commit comments

Comments
 (0)