diff --git a/src/bin/cargo/commands/help.rs b/src/bin/cargo/commands/help.rs index 868b14822f6..b618cd8f6d5 100644 --- a/src/bin/cargo/commands/help.rs +++ b/src/bin/cargo/commands/help.rs @@ -1,9 +1,11 @@ use crate::aliased_command; use crate::command_prelude::*; + use cargo::drop_println; use cargo::util::errors::CargoResult; use cargo_util::paths::resolve_executable; use flate2::read::GzDecoder; + use std::ffi::OsStr; use std::ffi::OsString; use std::io::Read; @@ -15,56 +17,100 @@ const COMPRESSED_MAN: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/man.tgz" pub fn cli() -> Command { subcommand("help") .about("Displays help for a cargo command") - .arg(Arg::new("COMMAND").action(ArgAction::Set).add( - clap_complete::ArgValueCandidates::new(|| { - super::builtin() - .iter() - .map(|cmd| { - let name = cmd.get_name(); - clap_complete::CompletionCandidate::new(name) - .help(cmd.get_about().cloned()) - .hide(cmd.is_hide_set()) - }) - .collect() - }), - )) + .arg( + Arg::new("COMMAND") + .num_args(1..) + .action(ArgAction::Append) + .add(clap_complete::ArgValueCandidates::new( + get_completion_candidates, + )), + ) } pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { - let Some(subcommand) = args.get_one::("COMMAND") else { + let args_command = args + .get_many::("COMMAND") + .map(|vals| vals.map(String::as_str).collect::>()) + .unwrap_or_default(); + + if args_command.is_empty() { let _ = crate::cli::cli(gctx).print_help(); return Ok(()); - }; + } - // Expand alias first - let subcommand = match aliased_command(gctx, subcommand).ok().flatten() { - // If this alias is more than a simple subcommand pass-through, show the alias. - Some(argv) if argv.len() > 1 => { - let alias = argv.join(" "); - drop_println!(gctx, "`{}` is aliased to `{}`", subcommand, alias); - return Ok(()); - } - // Otherwise, resolve the alias into its subcommand. - Some(argv) => { - // An alias with an empty argv can be created via `"empty-alias" = ""`. - let first = argv.get(0).map(String::as_str).unwrap_or(subcommand); - first.to_string() + let cmd: String; + let lookup_parts: Vec<&str> = if args_command.len() == 1 { + // Expand alias first + let subcommand = args_command.first().unwrap(); + match aliased_command(gctx, subcommand).ok().flatten() { + Some(argv) if argv.len() > 1 => { + // If this alias is more than a simple subcommand pass-through, show the alias. + let alias = argv.join(" "); + drop_println!(gctx, "`{}` is aliased to `{}`", subcommand, alias); + return Ok(()); + } + // Otherwise, resolve the alias into its subcommand. + Some(argv) => { + // An alias with an empty argv can be created via `"empty-alias" = ""`. + cmd = argv + .into_iter() + .next() + .unwrap_or_else(|| subcommand.to_string()); + vec![cmd.as_str()] + } + None => args_command.clone(), } - None => subcommand.to_string(), + } else { + args_command.clone() }; - if super::builtin_exec(&subcommand).is_some() { - if try_help(&subcommand)? { - return Ok(()); + match find_builtin_cmd(&lookup_parts) { + Ok(path) => { + let man_page_name = path.join("-"); + if try_help(&man_page_name)? { + return Ok(()); + } + crate::execute_internal_subcommand( + gctx, + &[OsStr::new(&man_page_name), OsStr::new("--help")], + )?; + } + Err(FindError::UnknownCommand(cmd)) => { + if lookup_parts.len() == 1 { + if let Some(man_page_name) = find_builtin_cmd_dash_joined(cmd) { + if try_help(&man_page_name)? { + return Ok(()); + } + crate::execute_internal_subcommand( + gctx, + &[OsStr::new(&man_page_name), OsStr::new("--help")], + )?; + } else { + crate::execute_external_subcommand( + gctx, + cmd, + &[OsStr::new(cmd), OsStr::new("--help")], + )?; + } + } else { + let err = anyhow::format_err!( + "no such command: `{cmd}`\n\n\ + help: view all installed commands with `cargo --list`", + ); + return Err(err.into()); + } + } + Err(FindError::UnknownSubcommand { + valid_prefix, + invalid, + }) => { + let valid_prefix = valid_prefix.join(" "); + let err = anyhow::format_err!( + "no such command: `cargo {valid_prefix} {invalid}` \n\n\ + help: view available subcommands with `cargo {valid_prefix} --help`", + ); + return Err(err.into()); } - crate::execute_internal_subcommand(gctx, &[OsStr::new(&subcommand), OsStr::new("--help")])?; - } else { - // If not built-in, try giving `--help` to external command. - crate::execute_external_subcommand( - gctx, - &subcommand, - &[OsStr::new(&subcommand), OsStr::new("--help")], - )?; } Ok(()) @@ -141,3 +187,123 @@ fn write_and_spawn(name: &str, contents: &[u8], command: &str) -> CargoResult<() drop(cmd.wait()); Ok(()) } + +enum FindError<'a> { + /// The primary command was not found. + UnknownCommand(&'a str), + /// A subcommand in the path was not found. + UnknownSubcommand { + valid_prefix: Vec<&'a str>, + invalid: &'a str, + }, +} + +/// Finds a auiltin command. +fn find_builtin_cmd<'a>(parts: &[&'a str]) -> Result, FindError<'a>> { + let Some((first, rest)) = parts.split_first() else { + return Err(FindError::UnknownCommand("")); + }; + + let builtins = super::builtin(); + + let Some(mut current) = builtins + .iter() + .find(|cmd| cmd.get_name() == *first || cmd.get_all_aliases().any(|a| a == *first)) + else { + return Err(FindError::UnknownCommand(first)); + }; + + let mut path = vec![current.get_name().to_string()]; + + for (i, &part) in rest.iter().enumerate() { + let next = current + .get_subcommands() + .find(|cmd| cmd.get_name() == part || cmd.get_all_aliases().any(|a| a == part)); + if let Some(next) = next { + path.push(next.get_name().to_string()); + current = next; + } else { + let valid_prefix = [*first] + .into_iter() + .chain(rest[..i].iter().copied()) + .collect::>(); + return Err(FindError::UnknownSubcommand { + valid_prefix, + invalid: part, + }); + }; + } + + Ok(path) +} + +fn find_builtin_cmd_dash_joined(s: &str) -> Option { + let builtins = super::builtin(); + + for cmd in builtins.iter() { + if let Some(result) = try_match_cmd(cmd, s) { + return Some(result); + } + } + None +} + +/// Tries to match a single dash-joined argument against commands +fn try_match_cmd(cmd: &Command, arg: &str) -> Option { + let name = cmd.get_name(); + + if arg == name || cmd.get_all_aliases().any(|alias| alias == arg) { + return Some(name.to_string()); + } + + if let Some(rest) = arg.strip_prefix(name).and_then(|r| r.strip_prefix('-')) { + for cmd in cmd.get_subcommands() { + if let Some(sub_cmds) = try_match_cmd(cmd, rest) { + return Some(format!("{name}-{sub_cmds}")); + } + } + } + + for alias in cmd.get_all_aliases() { + if let Some(rest) = arg.strip_prefix(alias).and_then(|r| r.strip_prefix('-')) { + for cmd in cmd.get_subcommands() { + if let Some(sub_cmds) = try_match_cmd(cmd, rest) { + return Some(format!("{name}-{sub_cmds}")); + } + } + } + } + + None +} + +/// Returns dash-joined names for nested commands, +/// so they can be completed as single tokens. +fn get_completion_candidates() -> Vec { + fn walk( + cmd: Command, + prefix: Option<&String>, + candidates: &mut Vec, + ) { + let name = cmd.get_name(); + let key = match prefix { + Some(prefix) => format!("{prefix}-{name}"), + None => name.to_string(), + }; + + for cmd in cmd.get_subcommands() { + walk(cmd.clone(), Some(&key), candidates); + } + + let candidate = clap_complete::CompletionCandidate::new(&key) + .help(cmd.get_about().cloned()) + .hide(cmd.is_hide_set()); + candidates.push(candidate); + } + + let mut candidates = Vec::new(); + for cmd in super::builtin() { + walk(cmd, None, &mut candidates); + } + candidates +} diff --git a/src/bin/cargo/commands/report.rs b/src/bin/cargo/commands/report.rs index c2d03e86058..7a4271cb69e 100644 --- a/src/bin/cargo/commands/report.rs +++ b/src/bin/cargo/commands/report.rs @@ -25,7 +25,10 @@ pub fn cli() -> Command { ) .value_name("id"), ) - .arg_package("Package to display a report for"), + .arg_package("Package to display a report for") + .after_help(color_print::cstr!( + "Run `cargo help report future-incompatibilities` for more detailed information.\n" + )), ) .subcommand( subcommand("timings") diff --git a/src/doc/man/cargo-help.md b/src/doc/man/cargo-help.md index af9911c69d8..6654de2fbdb 100644 --- a/src/doc/man/cargo-help.md +++ b/src/doc/man/cargo-help.md @@ -12,6 +12,18 @@ cargo-help --- Get help for a Cargo command Prints a help message for the given command. +For commands with subcommands, separate the command levels with spaces. For +example, `cargo help report future-incompatibilities` displays help for the +`cargo report future-incompatibilities` command. + +Spaces separate hierarchy levels only between a parent command and its +subcommands. Dashes that are part of a command's name, such as +`generate-lockfile`, must always be preserved. + +Multiple command levels can also be written as a single dash-joined word. +For example, `cargo help report-future-incompatibilities` is equivalent to +`cargo help report future-incompatibilities`. + ## OPTIONS ### Display Options @@ -38,7 +50,15 @@ Prints a help message for the given command. cargo help build -2. Help is also available with the `--help` flag: +2. Get help for a nested command: + + cargo help report future-incompatibilities + +3. The dash-joined form also works: + + cargo help report-future-incompatibilities + +4. Help is also available with the `--help` flag: cargo build --help diff --git a/src/doc/man/generated_txt/cargo-help.txt b/src/doc/man/generated_txt/cargo-help.txt index 1b16b53cd07..63d8726800b 100644 --- a/src/doc/man/generated_txt/cargo-help.txt +++ b/src/doc/man/generated_txt/cargo-help.txt @@ -9,6 +9,18 @@ SYNOPSIS DESCRIPTION Prints a help message for the given command. + For commands with subcommands, separate the command levels with spaces. + For example, cargo help report future-incompatibilities displays help + for the cargo report future-incompatibilities command. + + Spaces separate hierarchy levels only between a parent command and its + subcommands. Dashes that are part of a command’s name, such as + generate-lockfile, must always be preserved. + + Multiple command levels can also be written as a single dash-joined + word. For example, cargo help report-future-incompatibilities is + equivalent to cargo help report future-incompatibilities. + OPTIONS Display Options -v, --verbose @@ -120,7 +132,15 @@ EXAMPLES cargo help build - 2. Help is also available with the --help flag: + 2. Get help for a nested command: + + cargo help report future-incompatibilities + + 3. The dash-joined form also works: + + cargo help report-future-incompatibilities + + 4. Help is also available with the --help flag: cargo build --help diff --git a/src/doc/src/commands/cargo-help.md b/src/doc/src/commands/cargo-help.md index 2e3a890d396..3f907577065 100644 --- a/src/doc/src/commands/cargo-help.md +++ b/src/doc/src/commands/cargo-help.md @@ -12,6 +12,18 @@ cargo-help --- Get help for a Cargo command Prints a help message for the given command. +For commands with subcommands, separate the command levels with spaces. For +example, `cargo help report future-incompatibilities` displays help for the +`cargo report future-incompatibilities` command. + +Spaces separate hierarchy levels only between a parent command and its +subcommands. Dashes that are part of a command's name, such as +`generate-lockfile`, must always be preserved. + +Multiple command levels can also be written as a single dash-joined word. +For example, `cargo help report-future-incompatibilities` is equivalent to +`cargo help report future-incompatibilities`. + ## OPTIONS ### Display Options @@ -145,7 +157,15 @@ details on environment variables that Cargo reads. cargo help build -2. Help is also available with the `--help` flag: +2. Get help for a nested command: + + cargo help report future-incompatibilities + +3. The dash-joined form also works: + + cargo help report-future-incompatibilities + +4. Help is also available with the `--help` flag: cargo build --help diff --git a/src/etc/man/cargo-help.1 b/src/etc/man/cargo-help.1 index 46b810b5e3c..d7d16422277 100644 --- a/src/etc/man/cargo-help.1 +++ b/src/etc/man/cargo-help.1 @@ -9,6 +9,18 @@ cargo\-help \[em] Get help for a Cargo command \fBcargo help\fR [\fIsubcommand\fR] .SH "DESCRIPTION" Prints a help message for the given command. +.sp +For commands with subcommands, separate the command levels with spaces. For +example, \fBcargo help report future\-incompatibilities\fR displays help for the +\fBcargo report future\-incompatibilities\fR command. +.sp +Spaces separate hierarchy levels only between a parent command and its +subcommands. Dashes that are part of a command\[cq]s name, such as +\fBgenerate\-lockfile\fR, must always be preserved. +.sp +Multiple command levels can also be written as a single dash\-joined word. +For example, \fBcargo help report\-future\-incompatibilities\fR is equivalent to +\fBcargo help report future\-incompatibilities\fR\&. .SH "OPTIONS" .SS "Display Options" .sp @@ -155,7 +167,27 @@ cargo help build .RE .sp .RS 4 -\h'-04' 2.\h'+01'Help is also available with the \fB\-\-help\fR flag: +\h'-04' 2.\h'+01'Get help for a nested command: +.sp +.RS 4 +.nf +cargo help report future\-incompatibilities +.fi +.RE +.RE +.sp +.RS 4 +\h'-04' 3.\h'+01'The dash\-joined form also works: +.sp +.RS 4 +.nf +cargo help report\-future\-incompatibilities +.fi +.RE +.RE +.sp +.RS 4 +\h'-04' 4.\h'+01'Help is also available with the \fB\-\-help\fR flag: .sp .RS 4 .nf diff --git a/tests/testsuite/cargo_help/help/stdout.term.svg b/tests/testsuite/cargo_help/help/stdout.term.svg index d96174b1420..9c218202366 100644 --- a/tests/testsuite/cargo_help/help/stdout.term.svg +++ b/tests/testsuite/cargo_help/help/stdout.term.svg @@ -24,13 +24,13 @@ - Usage: cargo[EXE] help [OPTIONS] [COMMAND] + Usage: cargo[EXE] help [OPTIONS] [COMMAND]... Arguments: - [COMMAND] + [COMMAND]... diff --git a/tests/testsuite/cargo_help/nested_alias_dash_joined/mod.rs b/tests/testsuite/cargo_help/nested_alias_dash_joined/mod.rs index 0f59e38d4df..d1d2dfc84d5 100644 --- a/tests/testsuite/cargo_help/nested_alias_dash_joined/mod.rs +++ b/tests/testsuite/cargo_help/nested_alias_dash_joined/mod.rs @@ -8,7 +8,7 @@ fn case() { .arg("help") .arg("report-future-incompat") .assert() - .code(101) + .success() .stdout_eq(file!["stdout.term.txt"]) .stderr_eq(file!["stderr.term.svg"]); } diff --git a/tests/testsuite/cargo_help/nested_alias_dash_joined/stderr.term.svg b/tests/testsuite/cargo_help/nested_alias_dash_joined/stderr.term.svg index c9a39bc8e59..824d5a945cf 100644 --- a/tests/testsuite/cargo_help/nested_alias_dash_joined/stderr.term.svg +++ b/tests/testsuite/cargo_help/nested_alias_dash_joined/stderr.term.svg @@ -1,13 +1,11 @@ - + diff --git a/tests/testsuite/cargo_help/nested_alias_dash_joined/stdout.term.txt b/tests/testsuite/cargo_help/nested_alias_dash_joined/stdout.term.txt index e69de29bb2d..6caa69b8030 100644 --- a/tests/testsuite/cargo_help/nested_alias_dash_joined/stdout.term.txt +++ b/tests/testsuite/cargo_help/nested_alias_dash_joined/stdout.term.txt @@ -0,0 +1,148 @@ +CARGO-REPORT-FUTURE-INCOMPATIBILITIES(1) + +NAME + cargo-report-future-incompatibilities — Reports any crates which will + eventually stop compiling + +SYNOPSIS + cargo report future-incompatibilities [options] + +DESCRIPTION + Displays a report of future-incompatible warnings that were emitted + during previous builds. These are warnings for changes that may become + hard errors in the future, causing dependencies to stop building in a + future version of rustc. + + For more, see the chapter on Future incompat report + . + +OPTIONS + --id id + Show the report with the specified Cargo-generated id. If not + specified, shows the most recent report. + + Package Selection + By default, the package in the current working directory is selected. + The -p flag can be used to choose a different package in a workspace. + + -p spec, --package spec + The package to display a report for. See cargo-pkgid(1) for the SPEC + format. + + Display Options + -v, --verbose + Use verbose output. May be specified twice for “very verbose” + output which includes extra output such as dependency warnings and + build script output. May also be specified with the term.verbose + config value + . + + -q, --quiet + Do not print cargo log messages. May also be specified with the + term.quiet config value + . + + --color when + Control when colored output is used. Valid values: + + o auto (default): Automatically detect if color support is + available on the terminal. + + o always: Always display colors. + + o never: Never display colors. + + May also be specified with the term.color config value + . + + Manifest Options + --locked + Asserts that the exact same dependencies and versions are used as + when the existing Cargo.lock file was originally generated. Cargo + will exit with an error when either of the following scenarios + arises: + + o The lock file is missing. + + o Cargo attempted to change the lock file due to a different + dependency resolution. + + It may be used in environments where deterministic builds are + desired, such as in CI pipelines. + + --offline + Prevents Cargo from accessing the network for any reason. Without + this flag, Cargo will stop with an error if it needs to access the + network and the network is not available. With this flag, Cargo will + attempt to proceed without the network if possible. + + Beware that this may result in different dependency resolution than + online mode. Cargo will restrict itself to crates that are + downloaded locally, even if there might be a newer version as + indicated in the local copy of the index. See the cargo-fetch(1) + command to download dependencies before going offline. + + May also be specified with the net.offline config value + . + + --frozen + Equivalent to specifying both --locked and --offline. + + Common Options + +toolchain + If Cargo has been installed with rustup, and the first argument to + cargo begins with +, it will be interpreted as a rustup toolchain + name (such as +stable or +nightly). See the rustup documentation + for more + information about how toolchain overrides work. + + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. + + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. This + option must appear before the command name, for example cargo -C + path/to/my-project build. + + This option is only available on the nightly channel + and + requires the -Z unstable-options flag to enable (see #10098 + ). + + -h, --help + Prints help information. + + -Z flag + Unstable (nightly-only) flags to Cargo. Run cargo -Z help for + details. + +ENVIRONMENT + See the reference + + for details on environment variables that Cargo reads. + +EXIT STATUS + o 0: Cargo succeeded. + + o 101: Cargo failed to complete. + +EXAMPLES + 1. Display the latest future-incompat report: + + cargo report future-incompat + + 2. Display the latest future-incompat report for a specific package: + + cargo report future-incompat --package my-dep@0.0.1 + +SEE ALSO + cargo(1), cargo-report(1), cargo-build(1) + diff --git a/tests/testsuite/cargo_help/nested_cmd/mod.rs b/tests/testsuite/cargo_help/nested_cmd/mod.rs index 29dc2e3816a..644b3895b4d 100644 --- a/tests/testsuite/cargo_help/nested_cmd/mod.rs +++ b/tests/testsuite/cargo_help/nested_cmd/mod.rs @@ -9,7 +9,7 @@ fn case() { .arg("report") .arg("future-incompatibilities") .assert() - .code(1) + .success() .stdout_eq(file!["stdout.term.txt"]) .stderr_eq(file!["stderr.term.svg"]); } diff --git a/tests/testsuite/cargo_help/nested_cmd/stderr.term.svg b/tests/testsuite/cargo_help/nested_cmd/stderr.term.svg index cce37f84ba7..824d5a945cf 100644 --- a/tests/testsuite/cargo_help/nested_cmd/stderr.term.svg +++ b/tests/testsuite/cargo_help/nested_cmd/stderr.term.svg @@ -1,17 +1,11 @@ - + diff --git a/tests/testsuite/cargo_help/nested_cmd/stdout.term.txt b/tests/testsuite/cargo_help/nested_cmd/stdout.term.txt index e69de29bb2d..6caa69b8030 100644 --- a/tests/testsuite/cargo_help/nested_cmd/stdout.term.txt +++ b/tests/testsuite/cargo_help/nested_cmd/stdout.term.txt @@ -0,0 +1,148 @@ +CARGO-REPORT-FUTURE-INCOMPATIBILITIES(1) + +NAME + cargo-report-future-incompatibilities — Reports any crates which will + eventually stop compiling + +SYNOPSIS + cargo report future-incompatibilities [options] + +DESCRIPTION + Displays a report of future-incompatible warnings that were emitted + during previous builds. These are warnings for changes that may become + hard errors in the future, causing dependencies to stop building in a + future version of rustc. + + For more, see the chapter on Future incompat report + . + +OPTIONS + --id id + Show the report with the specified Cargo-generated id. If not + specified, shows the most recent report. + + Package Selection + By default, the package in the current working directory is selected. + The -p flag can be used to choose a different package in a workspace. + + -p spec, --package spec + The package to display a report for. See cargo-pkgid(1) for the SPEC + format. + + Display Options + -v, --verbose + Use verbose output. May be specified twice for “very verbose” + output which includes extra output such as dependency warnings and + build script output. May also be specified with the term.verbose + config value + . + + -q, --quiet + Do not print cargo log messages. May also be specified with the + term.quiet config value + . + + --color when + Control when colored output is used. Valid values: + + o auto (default): Automatically detect if color support is + available on the terminal. + + o always: Always display colors. + + o never: Never display colors. + + May also be specified with the term.color config value + . + + Manifest Options + --locked + Asserts that the exact same dependencies and versions are used as + when the existing Cargo.lock file was originally generated. Cargo + will exit with an error when either of the following scenarios + arises: + + o The lock file is missing. + + o Cargo attempted to change the lock file due to a different + dependency resolution. + + It may be used in environments where deterministic builds are + desired, such as in CI pipelines. + + --offline + Prevents Cargo from accessing the network for any reason. Without + this flag, Cargo will stop with an error if it needs to access the + network and the network is not available. With this flag, Cargo will + attempt to proceed without the network if possible. + + Beware that this may result in different dependency resolution than + online mode. Cargo will restrict itself to crates that are + downloaded locally, even if there might be a newer version as + indicated in the local copy of the index. See the cargo-fetch(1) + command to download dependencies before going offline. + + May also be specified with the net.offline config value + . + + --frozen + Equivalent to specifying both --locked and --offline. + + Common Options + +toolchain + If Cargo has been installed with rustup, and the first argument to + cargo begins with +, it will be interpreted as a rustup toolchain + name (such as +stable or +nightly). See the rustup documentation + for more + information about how toolchain overrides work. + + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. + + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. This + option must appear before the command name, for example cargo -C + path/to/my-project build. + + This option is only available on the nightly channel + and + requires the -Z unstable-options flag to enable (see #10098 + ). + + -h, --help + Prints help information. + + -Z flag + Unstable (nightly-only) flags to Cargo. Run cargo -Z help for + details. + +ENVIRONMENT + See the reference + + for details on environment variables that Cargo reads. + +EXIT STATUS + o 0: Cargo succeeded. + + o 101: Cargo failed to complete. + +EXAMPLES + 1. Display the latest future-incompat report: + + cargo report future-incompat + + 2. Display the latest future-incompat report for a specific package: + + cargo report future-incompat --package my-dep@0.0.1 + +SEE ALSO + cargo(1), cargo-report(1), cargo-build(1) + diff --git a/tests/testsuite/cargo_help/nested_cmd_dash_joined/mod.rs b/tests/testsuite/cargo_help/nested_cmd_dash_joined/mod.rs index 88a8757b4f6..b01a3697f47 100644 --- a/tests/testsuite/cargo_help/nested_cmd_dash_joined/mod.rs +++ b/tests/testsuite/cargo_help/nested_cmd_dash_joined/mod.rs @@ -8,7 +8,7 @@ fn case() { .arg("help") .arg("report-future-incompatibilities") .assert() - .code(101) + .success() .stdout_eq(file!["stdout.term.txt"]) .stderr_eq(file!["stderr.term.svg"]); } diff --git a/tests/testsuite/cargo_help/nested_cmd_dash_joined/stderr.term.svg b/tests/testsuite/cargo_help/nested_cmd_dash_joined/stderr.term.svg index f9bcdfb420e..824d5a945cf 100644 --- a/tests/testsuite/cargo_help/nested_cmd_dash_joined/stderr.term.svg +++ b/tests/testsuite/cargo_help/nested_cmd_dash_joined/stderr.term.svg @@ -1,13 +1,11 @@ - + diff --git a/tests/testsuite/cargo_help/nested_cmd_dash_joined/stdout.term.txt b/tests/testsuite/cargo_help/nested_cmd_dash_joined/stdout.term.txt index e69de29bb2d..6caa69b8030 100644 --- a/tests/testsuite/cargo_help/nested_cmd_dash_joined/stdout.term.txt +++ b/tests/testsuite/cargo_help/nested_cmd_dash_joined/stdout.term.txt @@ -0,0 +1,148 @@ +CARGO-REPORT-FUTURE-INCOMPATIBILITIES(1) + +NAME + cargo-report-future-incompatibilities — Reports any crates which will + eventually stop compiling + +SYNOPSIS + cargo report future-incompatibilities [options] + +DESCRIPTION + Displays a report of future-incompatible warnings that were emitted + during previous builds. These are warnings for changes that may become + hard errors in the future, causing dependencies to stop building in a + future version of rustc. + + For more, see the chapter on Future incompat report + . + +OPTIONS + --id id + Show the report with the specified Cargo-generated id. If not + specified, shows the most recent report. + + Package Selection + By default, the package in the current working directory is selected. + The -p flag can be used to choose a different package in a workspace. + + -p spec, --package spec + The package to display a report for. See cargo-pkgid(1) for the SPEC + format. + + Display Options + -v, --verbose + Use verbose output. May be specified twice for “very verbose” + output which includes extra output such as dependency warnings and + build script output. May also be specified with the term.verbose + config value + . + + -q, --quiet + Do not print cargo log messages. May also be specified with the + term.quiet config value + . + + --color when + Control when colored output is used. Valid values: + + o auto (default): Automatically detect if color support is + available on the terminal. + + o always: Always display colors. + + o never: Never display colors. + + May also be specified with the term.color config value + . + + Manifest Options + --locked + Asserts that the exact same dependencies and versions are used as + when the existing Cargo.lock file was originally generated. Cargo + will exit with an error when either of the following scenarios + arises: + + o The lock file is missing. + + o Cargo attempted to change the lock file due to a different + dependency resolution. + + It may be used in environments where deterministic builds are + desired, such as in CI pipelines. + + --offline + Prevents Cargo from accessing the network for any reason. Without + this flag, Cargo will stop with an error if it needs to access the + network and the network is not available. With this flag, Cargo will + attempt to proceed without the network if possible. + + Beware that this may result in different dependency resolution than + online mode. Cargo will restrict itself to crates that are + downloaded locally, even if there might be a newer version as + indicated in the local copy of the index. See the cargo-fetch(1) + command to download dependencies before going offline. + + May also be specified with the net.offline config value + . + + --frozen + Equivalent to specifying both --locked and --offline. + + Common Options + +toolchain + If Cargo has been installed with rustup, and the first argument to + cargo begins with +, it will be interpreted as a rustup toolchain + name (such as +stable or +nightly). See the rustup documentation + for more + information about how toolchain overrides work. + + --config KEY=VALUE or PATH + Overrides a Cargo configuration value. The argument should be in + TOML syntax of KEY=VALUE, or provided as a path to an extra + configuration file. This flag may be specified multiple times. See + the command-line overrides section + + for more information. + + -C PATH + Changes the current working directory before executing any specified + operations. This affects things like where cargo looks by default + for the project manifest (Cargo.toml), as well as the directories + searched for discovering .cargo/config.toml, for example. This + option must appear before the command name, for example cargo -C + path/to/my-project build. + + This option is only available on the nightly channel + and + requires the -Z unstable-options flag to enable (see #10098 + ). + + -h, --help + Prints help information. + + -Z flag + Unstable (nightly-only) flags to Cargo. Run cargo -Z help for + details. + +ENVIRONMENT + See the reference + + for details on environment variables that Cargo reads. + +EXIT STATUS + o 0: Cargo succeeded. + + o 101: Cargo failed to complete. + +EXAMPLES + 1. Display the latest future-incompat report: + + cargo report future-incompat + + 2. Display the latest future-incompat report for a specific package: + + cargo report future-incompat --package my-dep@0.0.1 + +SEE ALSO + cargo(1), cargo-report(1), cargo-build(1) + diff --git a/tests/testsuite/cargo_help/nested_cmd_with_extra_flags/stderr.term.svg b/tests/testsuite/cargo_help/nested_cmd_with_extra_flags/stderr.term.svg index cce37f84ba7..b70ca67bcc9 100644 --- a/tests/testsuite/cargo_help/nested_cmd_with_extra_flags/stderr.term.svg +++ b/tests/testsuite/cargo_help/nested_cmd_with_extra_flags/stderr.term.svg @@ -1,4 +1,4 @@ - + - Usage: cargo[EXE] help <COMMAND> + Usage: cargo[EXE] help <COMMAND>... diff --git a/tests/testsuite/cargo_report_future_incompat/help/stdout.term.svg b/tests/testsuite/cargo_report_future_incompat/help/stdout.term.svg index 8392fecb480..c15006871d0 100644 --- a/tests/testsuite/cargo_report_future_incompat/help/stdout.term.svg +++ b/tests/testsuite/cargo_report_future_incompat/help/stdout.term.svg @@ -1,4 +1,4 @@ - +