Skip to content

Commit

Permalink
fix(help): Consistently use SCREAMING_CASE for value names
Browse files Browse the repository at this point in the history
- We have some positional value names that are SCREAMING_CASE and some
  that aren't
- All of the value names for our flags are already SCREAMING_CASE
  • Loading branch information
epage committed Oct 17, 2023
1 parent 87f4b1b commit f715879
Show file tree
Hide file tree
Showing 34 changed files with 66 additions and 46 deletions.
1 change: 1 addition & 0 deletions src/bin/cargo/commands/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub fn cli() -> Command {
)
.arg(
Arg::new("args")
.value_name("ARGS")
.help("Arguments for the bench binary")
.num_args(0..)
.last(true),
Expand Down
7 changes: 6 additions & 1 deletion src/bin/cargo/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ use cargo::ops;
pub fn cli() -> Command {
subcommand("init")
.about("Create a new cargo package in an existing directory")
.arg(Arg::new("path").action(ArgAction::Set).default_value("."))
.arg(
Arg::new("path")
.value_name("PATH")
.action(ArgAction::Set)
.default_value("."),
)
.arg_new_opts()
.arg_registry("Registry to use")
.arg_quiet()
Expand Down
7 changes: 6 additions & 1 deletion src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ use cargo_util::paths;
pub fn cli() -> Command {
subcommand("install")
.about("Install a Rust binary. Default location is $HOME/.cargo/bin")
.arg(Arg::new("crate").value_parser(parse_crate).num_args(0..))
.arg(
Arg::new("crate")
.value_name("CRATE")
.value_parser(parse_crate)
.num_args(0..),
)
.arg(
opt("version", "Specify a version to install")
.alias("vers")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::command_prelude::*;
pub fn cli() -> Command {
subcommand("login")
.about("Log in to a registry.")
.arg(Arg::new("token").action(ArgAction::Set))
.arg(Arg::new("token").value_name("TOKEN").action(ArgAction::Set))
.arg_registry("Registry to use")
.arg(
Arg::new("args")
Expand Down
7 changes: 6 additions & 1 deletion src/bin/cargo/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ use cargo::ops;
pub fn cli() -> Command {
subcommand("new")
.about("Create a new cargo package at <path>")
.arg(Arg::new("path").action(ArgAction::Set).required(true))
.arg(
Arg::new("path")
.value_name("PATH")
.action(ArgAction::Set)
.required(true),
)
.arg_new_opts()
.arg_registry("Registry to use")
.arg_quiet()
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cargo_credential::Secret;
pub fn cli() -> Command {
subcommand("owner")
.about("Manage the owners of a crate on the registry")
.arg(Arg::new("crate").action(ArgAction::Set))
.arg(Arg::new("crate").value_name("CRATE").action(ArgAction::Set))
.arg(
multi_opt(
"add",
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/pkgid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cargo::util::print_available_packages;
pub fn cli() -> Command {
subcommand("pkgid")
.about("Print a fully qualified package specification")
.arg(Arg::new("spec").action(ArgAction::Set))
.arg(Arg::new("spec").value_name("SPEC").action(ArgAction::Set))
.arg_quiet()
.arg_package("Argument to get the package ID specifier for")
.arg_manifest_path()
Expand Down
1 change: 1 addition & 0 deletions src/bin/cargo/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn cli() -> Command {
.about("Run a binary or example of the local package")
.arg(
Arg::new("args")
.value_name("ARGS")
.help("Arguments for the binary or example to run")
.value_parser(value_parser!(OsString))
.num_args(0..)
Expand Down
1 change: 1 addition & 0 deletions src/bin/cargo/commands/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub fn cli() -> Command {
.about("Compile a package, and pass extra options to the compiler")
.arg(
Arg::new("args")
.value_name("ARGS")
.num_args(0..)
.help("Extra rustc flags")
.trailing_var_arg(true),
Expand Down
1 change: 1 addition & 0 deletions src/bin/cargo/commands/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub fn cli() -> Command {
.about("Build a package's documentation, using specified custom flags.")
.arg(
Arg::new("args")
.value_name("ARGS")
.help("Extra rustdoc flags")
.num_args(0..)
.trailing_var_arg(true),
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cargo::ops;
pub fn cli() -> Command {
subcommand("search")
.about("Search packages in crates.io")
.arg(Arg::new("query").num_args(0..))
.arg(Arg::new("query").value_name("QUERY").num_args(0..))
.arg(
opt(
"limit",
Expand Down
1 change: 1 addition & 0 deletions src/bin/cargo/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn cli() -> Command {
)
.arg(
Arg::new("args")
.value_name("ARGS")
.help("Arguments for the test binary")
.num_args(0..)
.last(true),
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cargo::ops;
pub fn cli() -> Command {
subcommand("uninstall")
.about("Remove a Rust binary")
.arg(Arg::new("spec").num_args(0..))
.arg(Arg::new("spec").value_name("SPEC").num_args(0..))
.arg(opt("root", "Directory to uninstall packages from").value_name("DIR"))
.arg_quiet()
.arg_package_spec_simple("Package to uninstall")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/yank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use cargo_credential::Secret;
pub fn cli() -> Command {
subcommand("yank")
.about("Remove a pushed crate from the index")
.arg(Arg::new("crate").action(ArgAction::Set))
.arg(Arg::new("crate").value_name("CRATE").action(ArgAction::Set))
.arg(
opt("version", "The version to yank or un-yank")
.alias("vers")
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_bench/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Execute all benchmarks of a local package

Usage: cargo[EXE] bench [OPTIONS] [BENCHNAME] [-- [args]...]
Usage: cargo bench [OPTIONS] [BENCHNAME] [-- [ARGS]...]

Arguments:
[BENCHNAME] If specified, only run benches containing this string in their names
[args]... Arguments for the bench binary
[ARGS]... Arguments for the bench binary

Options:
--no-run Compile, but don't run benchmarks
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_bench/no_keep_going/stderr.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ error: unexpected argument '--keep-going' found

tip: use `--no-fail-fast` to run as many tests as possible regardless of failure

Usage: cargo[EXE] bench [OPTIONS] [BENCHNAME] [-- [args]...]
Usage: cargo bench [OPTIONS] [BENCHNAME] [-- [ARGS]...]

For more information, try '--help'.
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_init/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Create a new cargo package in an existing directory

Usage: cargo[EXE] init [OPTIONS] [path]
Usage: cargo init [OPTIONS] [PATH]

Arguments:
[path] [default: .]
[PATH] [default: .]

Options:
--vcs <VCS> Initialize a new repository for the given version control system,
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_init/unknown_flags/stderr.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ error: unexpected argument '--flag' found

tip: to pass '--flag' as a value, use '-- --flag'

Usage: cargo[EXE] init <path>
Usage: cargo init <PATH>

For more information, try '--help'.
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 install [OPTIONS] [CRATE]...

Arguments:
[crate]...
[CRATE]...

Options:
--version <VERSION> Specify a version to install
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_login/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Log in to a registry.

Usage: cargo[EXE] login [OPTIONS] [token] [-- [args]...]
Usage: cargo login [OPTIONS] [TOKEN] [-- [args]...]

Arguments:
[token]
[TOKEN]
[args]... Additional arguments for the credential provider

Options:
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_new/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Create a new cargo package at <path>

Usage: cargo[EXE] new [OPTIONS] <path>
Usage: cargo new [OPTIONS] <PATH>

Arguments:
<path>
<PATH>

Options:
--vcs <VCS> Initialize a new repository for the given version control system,
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_owner/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Manage the owners of a crate on the registry

Usage: cargo[EXE] owner [OPTIONS] [crate]
Usage: cargo owner [OPTIONS] [CRATE]

Arguments:
[crate]
[CRATE]

Options:
-a, --add <LOGIN> Name of a user or team to invite as an owner
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_pkgid/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Print a fully qualified package specification

Usage: cargo[EXE] pkgid [OPTIONS] [spec]
Usage: cargo pkgid [OPTIONS] [SPEC]

Arguments:
[spec]
[SPEC]

Options:
-q, --quiet Do not print cargo log messages
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_run/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Run a binary or example of the local package

Usage: cargo[EXE] run [OPTIONS] [args]...
Usage: cargo run [OPTIONS] [ARGS]...

Arguments:
[args]... Arguments for the binary or example to run
[ARGS]... Arguments for the binary or example to run

Options:
--ignore-rust-version Ignore `rust-version` specification in packages
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_rustc/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Compile a package, and pass extra options to the compiler

Usage: cargo[EXE] rustc [OPTIONS] [args]...
Usage: cargo rustc [OPTIONS] [ARGS]...

Arguments:
[args]... Extra rustc flags
[ARGS]... Extra rustc flags

Options:
--print <INFO> Output compiler information without compiling
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_rustdoc/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Build a package's documentation, using specified custom flags.

Usage: cargo[EXE] rustdoc [OPTIONS] [args]...
Usage: cargo rustdoc [OPTIONS] [ARGS]...

Arguments:
[args]... Extra rustdoc flags
[ARGS]... Extra rustdoc flags

Options:
--open Opens the docs in a browser after the operation
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_search/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Search packages in crates.io

Usage: cargo[EXE] search [OPTIONS] [query]...
Usage: cargo search [OPTIONS] [QUERY]...

Arguments:
[query]...
[QUERY]...

Options:
--limit <LIMIT> Limit the number of results (default: 10, max: 100)
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_test/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Execute all unit and integration tests and build examples of a local package

Usage: cargo[EXE] test [OPTIONS] [TESTNAME] [-- [args]...]
Usage: cargo test [OPTIONS] [TESTNAME] [-- [ARGS]...]

Arguments:
[TESTNAME] If specified, only run tests containing this string in their names
[args]... Arguments for the test binary
[ARGS]... Arguments for the test binary

Options:
--doc Test only this library's documentation
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_test/no_keep_going/stderr.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ error: unexpected argument '--keep-going' found

tip: use `--no-fail-fast` to run as many tests as possible regardless of failure

Usage: cargo[EXE] test [OPTIONS] [TESTNAME] [-- [args]...]
Usage: cargo test [OPTIONS] [TESTNAME] [-- [ARGS]...]

For more information, try '--help'.
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_uninstall/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Remove a Rust binary

Usage: cargo[EXE] uninstall [OPTIONS] [spec]...
Usage: cargo uninstall [OPTIONS] [SPEC]...

Arguments:
[spec]...
[SPEC]...

Options:
--root <DIR> Directory to uninstall packages from
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_yank/help/stdout.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Remove a pushed crate from the index

Usage: cargo[EXE] yank [OPTIONS] [crate]
Usage: cargo yank [OPTIONS] [CRATE]

Arguments:
[crate]
[CRATE]

Options:
--version <VERSION> The version to yank or un-yank
Expand Down
6 changes: 3 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]...': missing crate name before '@'
For more information, try '--help'.
",
Expand Down Expand Up @@ -1844,7 +1844,7 @@ 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]...': crate name is empty")
.run();
}

Expand Down Expand Up @@ -2455,7 +2455,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]...
For more information, try '--help'.
",
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn no_argument() {
.with_stderr_contains(
"\
error: the following required arguments were not provided:
<path>
<PATH>
",
)
.run();
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ error: unexpected argument '--silent' found
tip: a similar argument exists: '--quiet'
Usage: cargo[EXE] run [OPTIONS] [args]...
Usage: cargo[EXE] run [OPTIONS] [ARGS]...
For more information, try '--help'.
",
Expand All @@ -65,7 +65,7 @@ error: unexpected argument '--silent' found
tip: a similar argument exists: '--quiet'
Usage: cargo[EXE] run [OPTIONS] [args]...
Usage: cargo[EXE] run [OPTIONS] [ARGS]...
For more information, try '--help'.
",
Expand Down

0 comments on commit f715879

Please sign in to comment.