diff --git a/Cargo.toml b/Cargo.toml index 77a2362e6..8c486911d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,7 +62,7 @@ toml_edit = { version = "0.14.3", features = ["serde", "easy", "perf"] } unicode-xid = "0.2.0" url = "2.2.2" walkdir = "2.2" -clap = "3.2.18" +clap = "4.0.4" unicode-width = "0.1.5" openssl = { version = '0.10.11', optional = true } im-rc = "15.0.0" diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 720d865c1..ba1d897ad 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -2,7 +2,7 @@ use anyhow::anyhow; use cargo::core::shell::Shell; use cargo::core::{features, CliUnstable}; use cargo::{self, drop_print, drop_println, CliResult, Config}; -use clap::{AppSettings, Arg, ArgMatches}; +use clap::{Arg, ArgMatches}; use itertools::Itertools; use std::collections::HashMap; use std::ffi::OsStr; @@ -69,7 +69,7 @@ Available unstable (nightly-only) flags: {} -Run with 'cargo -Z [FLAG] [SUBCOMMAND]'", +Run with 'cargo -Z [FLAG] [COMMAND]'", joined ); if !config.nightly_features_allowed { @@ -406,14 +406,12 @@ impl GlobalArgs { pub fn cli() -> Command { let is_rustup = std::env::var_os("RUSTUP_HOME").is_some(); let usage = if is_rustup { - "cargo [+toolchain] [OPTIONS] [SUBCOMMAND]" + "cargo [+toolchain] [OPTIONS] [COMMAND]" } else { - "cargo [OPTIONS] [SUBCOMMAND]" + "cargo [OPTIONS] [COMMAND]" }; Command::new("cargo") .allow_external_subcommands(true) - .allow_invalid_utf8_for_external_subcommands(true) - .setting(AppSettings::DeriveDisplayOrder) // Doesn't mix well with our list of common cargo commands. See clap-rs/clap#3108 for // opening clap up to allow us to style our help template .disable_colored_help(true) @@ -424,10 +422,9 @@ pub fn cli() -> Command { "\ Rust's package manager -USAGE: - {usage} +Usage: {usage} -OPTIONS: +Options: {options} Some common cargo commands are (see all commands with --list): diff --git a/src/bin/cargo/commands/add.rs b/src/bin/cargo/commands/add.rs index eeffdff6c..0912abb9a 100644 --- a/src/bin/cargo/commands/add.rs +++ b/src/bin/cargo/commands/add.rs @@ -14,21 +14,19 @@ use cargo::CargoResult; pub fn cli() -> Command { clap::Command::new("add") - .setting(clap::AppSettings::DeriveDisplayOrder) .about("Add dependencies to a Cargo.toml manifest file") .override_usage( "\ - cargo add [OPTIONS] [@] ... - cargo add [OPTIONS] --path ... - cargo add [OPTIONS] --git ..." + cargo add [OPTIONS] [@] ... + cargo add [OPTIONS] --path ... + cargo add [OPTIONS] --git ..." ) .after_help("Run `cargo help add` for more detailed information.\n") .group(clap::ArgGroup::new("selected").multiple(true).required(true)) .args([ clap::Arg::new("crates") - .takes_value(true) .value_name("DEP_ID") - .multiple_values(true) + .num_args(0..) .help("Reference to a package to add as a dependency") .long_help( "Reference to a package to add as a dependency @@ -46,7 +44,6 @@ You can reference a package by: clap::Arg::new("features") .short('F') .long("features") - .takes_value(true) .value_name("FEATURES") .action(ArgAction::Append) .help("Space or comma separated list of features to activate"), @@ -65,7 +62,7 @@ The package will be removed from your features.") .overrides_with("optional"), clap::Arg::new("rename") .long("rename") - .takes_value(true) + .action(ArgAction::Set) .value_name("NAME") .help("Rename the dependency") .long_help("Rename the dependency @@ -79,7 +76,7 @@ Example uses: clap::Arg::new("package") .short('p') .long("package") - .takes_value(true) + .action(ArgAction::Set) .value_name("SPEC") .help("Package to modify"), ]) @@ -89,14 +86,14 @@ Example uses: .args([ clap::Arg::new("path") .long("path") - .takes_value(true) + .action(ArgAction::Set) .value_name("PATH") .help("Filesystem path to local crate to add") .group("selected") .conflicts_with("git"), clap::Arg::new("git") .long("git") - .takes_value(true) + .action(ArgAction::Set) .value_name("URI") .help("Git repository location") .long_help("Git repository location @@ -105,21 +102,21 @@ Without any other information, cargo will use latest commit on the main branch." .group("selected"), clap::Arg::new("branch") .long("branch") - .takes_value(true) + .action(ArgAction::Set) .value_name("BRANCH") .help("Git branch to download the crate from") .requires("git") .group("git-ref"), clap::Arg::new("tag") .long("tag") - .takes_value(true) + .action(ArgAction::Set) .value_name("TAG") .help("Git tag to download the crate from") .requires("git") .group("git-ref"), clap::Arg::new("rev") .long("rev") - .takes_value(true) + .action(ArgAction::Set) .value_name("REV") .help("Git reference to download the crate from") .long_help("Git reference to download the crate from @@ -129,7 +126,7 @@ This is the catch all, handling hashes to named references in remote repositorie .group("git-ref"), clap::Arg::new("registry") .long("registry") - .takes_value(true) + .action(ArgAction::Set) .value_name("NAME") .help("Package registry for this dependency"), ]) @@ -151,7 +148,7 @@ Build-dependencies are the only dependencies available for use by build scripts .group("section"), clap::Arg::new("target") .long("target") - .takes_value(true) + .action(ArgAction::Set) .value_name("TARGET") .value_parser(clap::builder::NonEmptyStringValueParser::new()) .help("Add as dependency to the given target platform") diff --git a/src/bin/cargo/commands/bench.rs b/src/bin/cargo/commands/bench.rs index b7fe001b3..0906c645d 100644 --- a/src/bin/cargo/commands/bench.rs +++ b/src/bin/cargo/commands/bench.rs @@ -8,13 +8,13 @@ pub fn cli() -> Command { .arg_quiet() .arg( Arg::new("BENCHNAME") + .action(ArgAction::Set) .help("If specified, only run benches containing this string in their names"), ) .arg( Arg::new("args") .help("Arguments for the bench binary") - .multiple_values(true) - .last(true), + .num_args(0..), ) .arg_targets_all( "Benchmark only this package's library", diff --git a/src/bin/cargo/commands/config.rs b/src/bin/cargo/commands/config.rs index f93e741c6..87122d428 100644 --- a/src/bin/cargo/commands/config.rs +++ b/src/bin/cargo/commands/config.rs @@ -9,7 +9,11 @@ pub fn cli() -> Command { .arg_required_else_help(true) .subcommand( subcommand("get") - .arg(Arg::new("key").help("The config key to display")) + .arg( + Arg::new("key") + .action(ArgAction::Set) + .help("The config key to display"), + ) .arg( opt("format", "Display format") .value_parser(cargo_config::ConfigFormat::POSSIBLE_VALUES) diff --git a/src/bin/cargo/commands/git_checkout.rs b/src/bin/cargo/commands/git_checkout.rs index 1b6aed3e8..90be9bc55 100644 --- a/src/bin/cargo/commands/git_checkout.rs +++ b/src/bin/cargo/commands/git_checkout.rs @@ -1,10 +1,10 @@ use crate::command_prelude::*; -const REMOVED: &str = "The `git-checkout` subcommand has been removed."; +const REMOVED: &str = "The `git-checkout` command has been removed."; pub fn cli() -> Command { subcommand("git-checkout") - .about("This subcommand has been removed") + .about("This command has been removed") .hide(true) .override_help(REMOVED) } diff --git a/src/bin/cargo/commands/help.rs b/src/bin/cargo/commands/help.rs index 9e4c9ee2d..523268dbc 100644 --- a/src/bin/cargo/commands/help.rs +++ b/src/bin/cargo/commands/help.rs @@ -15,11 +15,11 @@ const COMPRESSED_MAN: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/man.tgz" pub fn cli() -> Command { subcommand("help") .about("Displays help for a cargo subcommand") - .arg(Arg::new("SUBCOMMAND")) + .arg(Arg::new("COMMAND").action(ArgAction::Set)) } pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { - let subcommand = args.get_one::("SUBCOMMAND"); + let subcommand = args.get_one::("COMMAND"); if let Some(subcommand) = subcommand { if !try_help(config, subcommand)? { crate::execute_external_subcommand( diff --git a/src/bin/cargo/commands/init.rs b/src/bin/cargo/commands/init.rs index b1a1d445b..b280d4fe4 100644 --- a/src/bin/cargo/commands/init.rs +++ b/src/bin/cargo/commands/init.rs @@ -6,7 +6,7 @@ pub fn cli() -> Command { subcommand("init") .about("Create a new cargo package in an existing directory") .arg_quiet() - .arg(Arg::new("path").default_value(".")) + .arg(Arg::new("path").action(ArgAction::Set).default_value(".")) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_new_opts() .after_help("Run `cargo help init` for more detailed information.\n") diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index a4d250d9b..22e297a1b 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -13,7 +13,7 @@ pub fn cli() -> Command { .arg( Arg::new("crate") .value_parser(clap::builder::NonEmptyStringValueParser::new()) - .multiple_values(true), + .num_args(0..), ) .arg( opt("version", "Specify a version to install") diff --git a/src/bin/cargo/commands/login.rs b/src/bin/cargo/commands/login.rs index 815afc25f..6dc74200a 100644 --- a/src/bin/cargo/commands/login.rs +++ b/src/bin/cargo/commands/login.rs @@ -9,7 +9,7 @@ pub fn cli() -> Command { If token is not specified, it will be read from stdin.", ) .arg_quiet() - .arg(Arg::new("token")) + .arg(Arg::new("token").action(ArgAction::Set)) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .after_help("Run `cargo help login` for more detailed information.\n") } diff --git a/src/bin/cargo/commands/new.rs b/src/bin/cargo/commands/new.rs index c23308ff6..18cf93d2e 100644 --- a/src/bin/cargo/commands/new.rs +++ b/src/bin/cargo/commands/new.rs @@ -6,7 +6,7 @@ pub fn cli() -> Command { subcommand("new") .about("Create a new cargo package at ") .arg_quiet() - .arg(Arg::new("path").required(true)) + .arg(Arg::new("path").action(ArgAction::Set).required(true)) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) .arg_new_opts() .after_help("Run `cargo help new` for more detailed information.\n") diff --git a/src/bin/cargo/commands/owner.rs b/src/bin/cargo/commands/owner.rs index 78f091231..2e0d818ba 100644 --- a/src/bin/cargo/commands/owner.rs +++ b/src/bin/cargo/commands/owner.rs @@ -6,7 +6,7 @@ pub fn cli() -> Command { subcommand("owner") .about("Manage the owners of a crate on the registry") .arg_quiet() - .arg(Arg::new("crate")) + .arg(Arg::new("crate").action(ArgAction::Set)) .arg( multi_opt( "add", diff --git a/src/bin/cargo/commands/pkgid.rs b/src/bin/cargo/commands/pkgid.rs index d2228f449..664db75bd 100644 --- a/src/bin/cargo/commands/pkgid.rs +++ b/src/bin/cargo/commands/pkgid.rs @@ -7,7 +7,7 @@ pub fn cli() -> Command { subcommand("pkgid") .about("Print a fully qualified package specification") .arg_quiet() - .arg(Arg::new("spec")) + .arg(Arg::new("spec").action(ArgAction::Set)) .arg_package("Argument to get the package ID specifier for") .arg_manifest_path() .after_help("Run `cargo help pkgid` for more detailed information.\n") diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs index 0049422a3..11657e78e 100644 --- a/src/bin/cargo/commands/run.rs +++ b/src/bin/cargo/commands/run.rs @@ -14,7 +14,7 @@ pub fn cli() -> Command { .arg( Arg::new("args") .value_parser(value_parser!(std::ffi::OsString)) - .multiple_values(true), + .num_args(0..), ) .arg_targets_bin_example( "Name of the bin target to run", diff --git a/src/bin/cargo/commands/rustc.rs b/src/bin/cargo/commands/rustc.rs index 26e0f0d42..63b48d644 100644 --- a/src/bin/cargo/commands/rustc.rs +++ b/src/bin/cargo/commands/rustc.rs @@ -10,7 +10,7 @@ pub fn cli() -> Command { .trailing_var_arg(true) .about("Compile a package, and pass extra options to the compiler") .arg_quiet() - .arg(Arg::new("args").multiple_values(true).help("Rustc flags")) + .arg(Arg::new("args").num_args(0..).help("Rustc flags")) .arg_package("Package to build") .arg_jobs() .arg_targets_all( diff --git a/src/bin/cargo/commands/rustdoc.rs b/src/bin/cargo/commands/rustdoc.rs index 89542dc44..af9aa66b9 100644 --- a/src/bin/cargo/commands/rustdoc.rs +++ b/src/bin/cargo/commands/rustdoc.rs @@ -7,7 +7,7 @@ pub fn cli() -> Command { .trailing_var_arg(true) .about("Build a package's documentation, using specified custom flags.") .arg_quiet() - .arg(Arg::new("args").multiple_values(true)) + .arg(Arg::new("args").num_args(0..)) .arg(flag( "open", "Opens the docs in a browser after the operation", diff --git a/src/bin/cargo/commands/search.rs b/src/bin/cargo/commands/search.rs index 5068f16b4..c55d932cc 100644 --- a/src/bin/cargo/commands/search.rs +++ b/src/bin/cargo/commands/search.rs @@ -8,7 +8,7 @@ pub fn cli() -> Command { subcommand("search") .about("Search packages in crates.io") .arg_quiet() - .arg(Arg::new("query").multiple_values(true)) + .arg(Arg::new("query").num_args(0..)) .arg_index() .arg( opt( diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs index 5cf696a98..339d16ac1 100644 --- a/src/bin/cargo/commands/test.rs +++ b/src/bin/cargo/commands/test.rs @@ -9,13 +9,13 @@ pub fn cli() -> Command { .about("Execute all unit and integration tests and build examples of a local package") .arg( Arg::new("TESTNAME") + .action(ArgAction::Set) .help("If specified, only run tests containing this string in their names"), ) .arg( Arg::new("args") .help("Arguments for the test binary") - .multiple_values(true) - .last(true), + .num_args(0..), ) .arg( flag( diff --git a/src/bin/cargo/commands/uninstall.rs b/src/bin/cargo/commands/uninstall.rs index 0c355151d..46654b668 100644 --- a/src/bin/cargo/commands/uninstall.rs +++ b/src/bin/cargo/commands/uninstall.rs @@ -6,7 +6,7 @@ pub fn cli() -> Command { subcommand("uninstall") .about("Remove a Rust binary") .arg_quiet() - .arg(Arg::new("spec").multiple_values(true)) + .arg(Arg::new("spec").num_args(0..)) .arg_package_spec_simple("Package to uninstall") .arg(multi_opt("bin", "NAME", "Only uninstall the binary NAME")) .arg(opt("root", "Directory to uninstall packages from").value_name("DIR")) diff --git a/src/bin/cargo/commands/vendor.rs b/src/bin/cargo/commands/vendor.rs index 254308280..1fd79ec51 100644 --- a/src/bin/cargo/commands/vendor.rs +++ b/src/bin/cargo/commands/vendor.rs @@ -9,6 +9,7 @@ pub fn cli() -> Command { .arg_manifest_path() .arg( Arg::new("path") + .action(ArgAction::Set) .value_parser(clap::value_parser!(PathBuf)) .help("Where to vendor crates (`vendor` by default)"), ) diff --git a/src/bin/cargo/commands/yank.rs b/src/bin/cargo/commands/yank.rs index 708023eeb..0f84a0a5a 100644 --- a/src/bin/cargo/commands/yank.rs +++ b/src/bin/cargo/commands/yank.rs @@ -6,7 +6,7 @@ pub fn cli() -> Command { subcommand("yank") .about("Remove a pushed crate from the index") .arg_quiet() - .arg(Arg::new("crate")) + .arg(Arg::new("crate").action(ArgAction::Set)) .arg( opt("version", "The version to yank or un-yank") .alias("vers") diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index e6fb71dd9..3c0c943e9 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -168,7 +168,7 @@ fn execute_external_subcommand(config: &Config, cmd: &str, args: &[&OsStr]) -> C None => { let err = if cmd.starts_with('+') { anyhow::format_err!( - "no such subcommand: `{}`\n\n\t\ + "no such command: `{}`\n\n\t\ Cargo does not handle `+toolchain` directives.\n\t\ Did you mean to invoke `cargo` through `rustup` instead?", cmd @@ -178,7 +178,7 @@ fn execute_external_subcommand(config: &Config, cmd: &str, args: &[&OsStr]) -> C let did_you_mean = closest_msg(cmd, suggestions.keys(), |c| c); anyhow::format_err!( - "no such subcommand: `{}`{}\n\n\t\ + "no such command: `{}`{}\n\n\t\ View all installed commands with `cargo --list`", cmd, did_you_mean diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 32fb6362d..bcaff34a6 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -20,12 +20,12 @@ use std::path::PathBuf; pub use crate::core::compiler::CompileMode; pub use crate::{CliError, CliResult, Config}; -pub use clap::{value_parser, AppSettings, Arg, ArgAction, ArgMatches}; +pub use clap::{value_parser, Arg, ArgAction, ArgMatches}; -pub type Command = clap::Command<'static>; +pub use clap::Command; pub trait CommandExt: Sized { - fn _arg(self, arg: Arg<'static>) -> Self; + fn _arg(self, arg: Arg) -> Self; /// Do not use this method, it is only for backwards compatibility. /// Use `arg_package_spec_no_all` instead. @@ -256,40 +256,34 @@ pub trait CommandExt: Sized { } impl CommandExt for Command { - fn _arg(self, arg: Arg<'static>) -> Self { + fn _arg(self, arg: Arg) -> Self { self.arg(arg) } } -pub fn flag(name: &'static str, help: &'static str) -> Arg<'static> { +pub fn flag(name: &'static str, help: &'static str) -> Arg { Arg::new(name) .long(name) .help(help) .action(ArgAction::SetTrue) } -pub fn opt(name: &'static str, help: &'static str) -> Arg<'static> { - Arg::new(name).long(name).help(help) +pub fn opt(name: &'static str, help: &'static str) -> Arg { + Arg::new(name).long(name).help(help).action(ArgAction::Set) } -pub fn optional_opt(name: &'static str, help: &'static str) -> Arg<'static> { - opt(name, help).min_values(0) +pub fn optional_opt(name: &'static str, help: &'static str) -> Arg { + opt(name, help).num_args(0..=1) } -pub fn optional_multi_opt( - name: &'static str, - value_name: &'static str, - help: &'static str, -) -> Arg<'static> { +pub fn optional_multi_opt(name: &'static str, value_name: &'static str, help: &'static str) -> Arg { opt(name, help) .value_name(value_name) + .num_args(0..=1) .action(ArgAction::Append) - .multiple_values(true) - .min_values(0) - .number_of_values(1) } -pub fn multi_opt(name: &'static str, value_name: &'static str, help: &'static str) -> Arg<'static> { +pub fn multi_opt(name: &'static str, value_name: &'static str, help: &'static str) -> Arg { opt(name, help) .value_name(value_name) .action(ArgAction::Append) @@ -297,8 +291,6 @@ pub fn multi_opt(name: &'static str, value_name: &'static str, help: &'static st pub fn subcommand(name: &'static str) -> Command { Command::new(name) - .dont_collapse_args_in_usage(true) - .setting(AppSettings::DeriveDisplayOrder) } /// Determines whether or not to gate `--profile` as unstable when resolving it. @@ -792,7 +784,7 @@ pub fn values_os(args: &ArgMatches, name: &str) -> Vec { } #[track_caller] -fn ignore_unknown(r: Result) -> T { +pub fn ignore_unknown(r: Result) -> T { match r { Ok(t) => t, Err(clap::parser::MatchesError::UnknownArgument { .. }) => Default::default(), diff --git a/tests/testsuite/cargo_add/dev_build_conflict/stderr.log b/tests/testsuite/cargo_add/dev_build_conflict/stderr.log index 7aee514e4..57f17e254 100644 --- a/tests/testsuite/cargo_add/dev_build_conflict/stderr.log +++ b/tests/testsuite/cargo_add/dev_build_conflict/stderr.log @@ -1,8 +1,7 @@ error: The argument '--dev' cannot be used with '--build' -USAGE: - cargo add [OPTIONS] [@] ... - cargo add [OPTIONS] --path ... - cargo add [OPTIONS] --git ... +Usage: cargo add [OPTIONS] [@] ... + cargo add [OPTIONS] --path ... + cargo add [OPTIONS] --git ... -For more information try --help +For more information try '--help' diff --git a/tests/testsuite/cargo_add/invalid_arg/stderr.log b/tests/testsuite/cargo_add/invalid_arg/stderr.log index d994681a4..6c2693070 100644 --- a/tests/testsuite/cargo_add/invalid_arg/stderr.log +++ b/tests/testsuite/cargo_add/invalid_arg/stderr.log @@ -1,10 +1,9 @@ error: Found argument '--flag' which wasn't expected, or isn't valid in this context - If you tried to supply `--flag` as a value rather than a flag, use `-- --flag` + If you tried to supply '--flag' as a value rather than a flag, use '-- --flag' -USAGE: - cargo add [OPTIONS] [@] ... - cargo add [OPTIONS] --path ... - cargo add [OPTIONS] --git ... +Usage: cargo add [OPTIONS] [@] ... + cargo add [OPTIONS] --path ... + cargo add [OPTIONS] --git ... -For more information try --help +For more information try '--help' diff --git a/tests/testsuite/cargo_add/invalid_target_empty/stderr.log b/tests/testsuite/cargo_add/invalid_target_empty/stderr.log index 5bc29bef9..3b11bc65a 100644 --- a/tests/testsuite/cargo_add/invalid_target_empty/stderr.log +++ b/tests/testsuite/cargo_add/invalid_target_empty/stderr.log @@ -1,3 +1,3 @@ error: The argument '--target ' requires a value but none was supplied -For more information try --help +For more information try '--help' diff --git a/tests/testsuite/cargo_add/no_args/stderr.log b/tests/testsuite/cargo_add/no_args/stderr.log index a046b3f3f..44ce2049a 100644 --- a/tests/testsuite/cargo_add/no_args/stderr.log +++ b/tests/testsuite/cargo_add/no_args/stderr.log @@ -1,9 +1,8 @@ error: The following required arguments were not provided: - |--git > + |--git > -USAGE: - cargo add [OPTIONS] [@] ... - cargo add [OPTIONS] --path ... - cargo add [OPTIONS] --git ... +Usage: cargo add [OPTIONS] [@] ... + cargo add [OPTIONS] --path ... + cargo add [OPTIONS] --git ... -For more information try --help +For more information try '--help' diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index 694b9a109..ad969d1ba 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -156,7 +156,7 @@ fn find_closest_capital_c_to_c() { .with_status(101) .with_stderr_contains( "\ -error: no such subcommand: `C` +error: no such command: `C` Did you mean `c`? ", @@ -170,7 +170,7 @@ fn find_closest_capital_b_to_b() { .with_status(101) .with_stderr_contains( "\ -error: no such subcommand: `B` +error: no such command: `B` Did you mean `b`? ", @@ -184,7 +184,7 @@ fn find_closest_biuld_to_build() { .with_status(101) .with_stderr_contains( "\ -error: no such subcommand: `biuld` +error: no such command: `biuld` Did you mean `build`? ", @@ -235,7 +235,7 @@ fn find_closest_alias() { .with_status(101) .with_stderr_contains( "\ -error: no such subcommand: `myalais` +error: no such command: `myalais` Did you mean `myalias`? ", @@ -247,7 +247,7 @@ error: no such subcommand: `myalais` .with_status(101) .with_stderr_contains( "\ -error: no such subcommand: `myalais` +error: no such command: `myalais` ", ) .with_stderr_does_not_contain( @@ -266,7 +266,7 @@ fn find_closest_dont_correct_nonsense() { .with_status(101) .with_stderr( "\ -[ERROR] no such subcommand: `there-is-no-way-that-there-is-a-command-close-to-this` +[ERROR] no such command: `there-is-no-way-that-there-is-a-command-close-to-this` View all installed commands with `cargo --list`", ) @@ -279,7 +279,7 @@ fn displays_subcommand_on_error() { .with_status(101) .with_stderr( "\ -[ERROR] no such subcommand: `invalid-command` +[ERROR] no such command: `invalid-command` View all installed commands with `cargo --list`", ) @@ -473,7 +473,7 @@ fn subcommand_leading_plus_output_contains() { .with_status(101) .with_stderr( "\ -error: no such subcommand: `+nightly` +error: no such command: `+nightly` Cargo does not handle `+toolchain` directives. Did you mean to invoke `cargo` through `rustup` instead?", @@ -487,7 +487,7 @@ fn full_did_you_mean() { .with_status(101) .with_stderr( "\ -error: no such subcommand: `bluid` +error: no such command: `bluid` Did you mean `build`? diff --git a/tests/testsuite/init/unknown_flags/stderr.log b/tests/testsuite/init/unknown_flags/stderr.log index 93e111d84..29c950537 100644 --- a/tests/testsuite/init/unknown_flags/stderr.log +++ b/tests/testsuite/init/unknown_flags/stderr.log @@ -1,8 +1,7 @@ error: Found argument '--flag' which wasn't expected, or isn't valid in this context - If you tried to supply `--flag` as a value rather than a flag, use `-- --flag` + If you tried to supply '--flag' as a value rather than a flag, use '-- --flag' -USAGE: - cargo[EXE] init +Usage: cargo[EXE] init -For more information try --help +For more information try '--help' diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 4bd679c0c..70fff6aaa 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1448,8 +1448,7 @@ fn not_both_vers_and_version() { .with_status(1) .with_stderr_contains( "\ -error: The argument '--version ' was provided more than once, \ -but cannot be used multiple times +error: The argument '--version ' was provided more than once, but cannot be used multiple times ", ) .run(); @@ -1652,7 +1651,7 @@ fn install_empty_argument() { .arg("") .with_status(1) .with_stderr_contains( - "[ERROR] The argument '...' requires a value but none was supplied", + "[ERROR] The argument '[crate]...' requires a value but none was supplied", ) .run(); } diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 0b7287db5..45174fa1f 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -1911,7 +1911,7 @@ fn cargo_metadata_bad_version() { .with_stderr_contains( "\ error: \"2\" isn't a valid value for '--format-version ' -[possible values: 1] + [possible values: 1] ", ) .run(); diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index 473770ed2..7b66bce32 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -107,7 +107,7 @@ fn no_argument() { .with_stderr_contains( "\ error: The following required arguments were not provided: - + ", ) .run(); diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index b75f2a8c3..390f28793 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -1314,9 +1314,16 @@ fn run_multiple_packages() { cargo().with_stdout("foo").run(); - cargo().arg("-p").arg("d1").arg("-p").arg("d2") - .with_status(1) - .with_stderr_contains("error: The argument '--package [...]' was provided more than once, but cannot be used multiple times").run(); + cargo() + .arg("-p") + .arg("d1") + .arg("-p") + .arg("d2") + .with_status(1) + .with_stderr_contains( + "error: The argument '--package []' was provided more than once, but cannot be used multiple times", + ) + .run(); cargo() .arg("-p") diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index d00818c85..d15cf68a1 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -551,8 +551,7 @@ fn fail_with_multiple_packages() { .with_status(1) .with_stderr_contains( "\ -error: The argument '--package [...]' was provided more than once, \ - but cannot be used multiple times +error: The argument '--package []' was provided more than once, but cannot be used multiple times ", ) .run(); diff --git a/tests/testsuite/vendor.rs b/tests/testsuite/vendor.rs index 6b5c22fd9..5d6165c49 100644 --- a/tests/testsuite/vendor.rs +++ b/tests/testsuite/vendor.rs @@ -405,10 +405,9 @@ fn test_sync_argument() { .with_stderr("\ error: Found argument 'test_vendor' which wasn't expected, or isn't valid in this context -USAGE: - cargo[EXE] vendor [OPTIONS] [path] +Usage: cargo[EXE] vendor [OPTIONS] [path] -For more information try --help", +For more information try '--help'", ) .with_status(1) .run();