mirror of
https://github.com/rust-lang/cargo
synced 2024-08-28 11:50:23 +00:00
Upgrade to Clap 3
- One parser change found by `cargo_config::includes` is that clap 2 would ignore any values after a `=` for flags. `cargo config --show-origin` is a flag but the test passed `--show-origin=yes` which happens to give the desired result for that test but is the same as `--show-origin=no` or `--show-origin=alien-invasion`. - The parser now panics when accessing an undefined attribute but clap takes advantage of that for sharing code across commands that have different subsets of arguments defined. I've extended clap so we can "look before you leap" and put the checks at the argument calls to start off with so its very clear what is tenuously shared. This allows us to go in either direction in the future, either addressing how we are sharing between commands or by moving this down into the extension methods and pretending this clap feature doesn't exist - On that topic, a test found clap-rs/clap#3263. For now, there is a hack in clap. Depending on how we fix that in clap for clap 4.0, we might need to re-address things in cargo. - `value_of_os` now requires setting `allow_invalid_utf8`, otherwise it asserts. To help catch this, I updated the argument definitions associated with lookups reported by: - `rg 'values?_os' src/` - `rg 'values?_of_os' src/` - clap now reports `2` for usage errors, so we had to bypass clap's `exit` call to keep the same exit code. BREAKING CHANGE: API now uses clap3
This commit is contained in:
parent
2478331215
commit
f17ecafc24
|
@ -61,7 +61,7 @@ toml = "0.5.7"
|
||||||
unicode-xid = "0.2.0"
|
unicode-xid = "0.2.0"
|
||||||
url = "2.2.2"
|
url = "2.2.2"
|
||||||
walkdir = "2.2"
|
walkdir = "2.2"
|
||||||
clap = "2.34.0"
|
clap = "3.0.5"
|
||||||
unicode-width = "0.1.5"
|
unicode-width = "0.1.5"
|
||||||
openssl = { version = '0.10.11', optional = true }
|
openssl = { version = '0.10.11', optional = true }
|
||||||
im-rc = "15.0.0"
|
im-rc = "15.0.0"
|
||||||
|
|
|
@ -35,8 +35,8 @@ pub fn main(config: &mut Config) -> CliResult {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if e.kind == clap::ErrorKind::UnrecognizedSubcommand {
|
if e.kind == clap::ErrorKind::UnrecognizedSubcommand {
|
||||||
// An unrecognized subcommand might be an external subcommand.
|
// An unrecognized subcommand might be an external subcommand.
|
||||||
let cmd = &e.info.as_ref().unwrap()[0].to_owned();
|
let cmd = e.info[0].clone();
|
||||||
return super::execute_external_subcommand(config, cmd, &[cmd, "--help"])
|
return super::execute_external_subcommand(config, &cmd, &[&cmd, "--help"])
|
||||||
.map_err(|_| e.into());
|
.map_err(|_| e.into());
|
||||||
} else {
|
} else {
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
|
@ -152,7 +152,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'",
|
||||||
}
|
}
|
||||||
|
|
||||||
let (cmd, subcommand_args) = match expanded_args.subcommand() {
|
let (cmd, subcommand_args) = match expanded_args.subcommand() {
|
||||||
(cmd, Some(args)) => (cmd, args),
|
Some((cmd, args)) => (cmd, args),
|
||||||
_ => {
|
_ => {
|
||||||
// No subcommand provided.
|
// No subcommand provided.
|
||||||
cli().print_help()?;
|
cli().print_help()?;
|
||||||
|
@ -236,10 +236,10 @@ fn add_ssl(version_string: &mut String) {
|
||||||
|
|
||||||
fn expand_aliases(
|
fn expand_aliases(
|
||||||
config: &mut Config,
|
config: &mut Config,
|
||||||
args: ArgMatches<'static>,
|
args: ArgMatches,
|
||||||
mut already_expanded: Vec<String>,
|
mut already_expanded: Vec<String>,
|
||||||
) -> Result<(ArgMatches<'static>, GlobalArgs), CliError> {
|
) -> Result<(ArgMatches, GlobalArgs), CliError> {
|
||||||
if let (cmd, Some(args)) = args.subcommand() {
|
if let Some((cmd, args)) = args.subcommand() {
|
||||||
match (
|
match (
|
||||||
commands::builtin_exec(cmd),
|
commands::builtin_exec(cmd),
|
||||||
super::aliased_command(config, cmd)?,
|
super::aliased_command(config, cmd)?,
|
||||||
|
@ -292,7 +292,7 @@ For more information, see issue #10049 <https://github.com/rust-lang/cargo/issue
|
||||||
.setting(AppSettings::NoBinaryName)
|
.setting(AppSettings::NoBinaryName)
|
||||||
.get_matches_from_safe(alias)?;
|
.get_matches_from_safe(alias)?;
|
||||||
|
|
||||||
let (new_cmd, _) = new_args.subcommand();
|
let new_cmd = new_args.subcommand_name().expect("subcommand is required");
|
||||||
already_expanded.push(cmd.to_string());
|
already_expanded.push(cmd.to_string());
|
||||||
if already_expanded.contains(&new_cmd.to_string()) {
|
if already_expanded.contains(&new_cmd.to_string()) {
|
||||||
// Crash if the aliases are corecursive / unresolvable
|
// Crash if the aliases are corecursive / unresolvable
|
||||||
|
@ -316,16 +316,20 @@ For more information, see issue #10049 <https://github.com/rust-lang/cargo/issue
|
||||||
|
|
||||||
fn config_configure(
|
fn config_configure(
|
||||||
config: &mut Config,
|
config: &mut Config,
|
||||||
args: &ArgMatches<'_>,
|
args: &ArgMatches,
|
||||||
subcommand_args: &ArgMatches<'_>,
|
subcommand_args: &ArgMatches,
|
||||||
global_args: GlobalArgs,
|
global_args: GlobalArgs,
|
||||||
) -> CliResult {
|
) -> CliResult {
|
||||||
let arg_target_dir = &subcommand_args.value_of_path("target-dir", config);
|
let arg_target_dir = &subcommand_args
|
||||||
|
._is_valid_arg("target-dir")
|
||||||
|
.then(|| subcommand_args.value_of_path("target-dir", config))
|
||||||
|
.flatten();
|
||||||
let verbose = global_args.verbose + args.occurrences_of("verbose") as u32;
|
let verbose = global_args.verbose + args.occurrences_of("verbose") as u32;
|
||||||
// quiet is unusual because it is redefined in some subcommands in order
|
// quiet is unusual because it is redefined in some subcommands in order
|
||||||
// to provide custom help text.
|
// to provide custom help text.
|
||||||
let quiet =
|
let quiet = args.is_present("quiet")
|
||||||
args.is_present("quiet") || subcommand_args.is_present("quiet") || global_args.quiet;
|
|| subcommand_args.is_valid_and_present("quiet")
|
||||||
|
|| global_args.quiet;
|
||||||
let global_color = global_args.color; // Extract so it can take reference.
|
let global_color = global_args.color; // Extract so it can take reference.
|
||||||
let color = args.value_of("color").or_else(|| global_color.as_deref());
|
let color = args.value_of("color").or_else(|| global_color.as_deref());
|
||||||
let frozen = args.is_present("frozen") || global_args.frozen;
|
let frozen = args.is_present("frozen") || global_args.frozen;
|
||||||
|
@ -353,11 +357,7 @@ fn config_configure(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_subcommand(
|
fn execute_subcommand(config: &mut Config, cmd: &str, subcommand_args: &ArgMatches) -> CliResult {
|
||||||
config: &mut Config,
|
|
||||||
cmd: &str,
|
|
||||||
subcommand_args: &ArgMatches<'_>,
|
|
||||||
) -> CliResult {
|
|
||||||
if let Some(exec) = commands::builtin_exec(cmd) {
|
if let Some(exec) = commands::builtin_exec(cmd) {
|
||||||
return exec(config, subcommand_args);
|
return exec(config, subcommand_args);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ struct GlobalArgs {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalArgs {
|
impl GlobalArgs {
|
||||||
fn new(args: &ArgMatches<'_>) -> GlobalArgs {
|
fn new(args: &ArgMatches) -> GlobalArgs {
|
||||||
GlobalArgs {
|
GlobalArgs {
|
||||||
verbose: args.occurrences_of("verbose") as u32,
|
verbose: args.occurrences_of("verbose") as u32,
|
||||||
quiet: args.is_present("quiet"),
|
quiet: args.is_present("quiet"),
|
||||||
|
@ -411,9 +411,12 @@ fn cli() -> App {
|
||||||
.settings(&[
|
.settings(&[
|
||||||
AppSettings::UnifiedHelpMessage,
|
AppSettings::UnifiedHelpMessage,
|
||||||
AppSettings::DeriveDisplayOrder,
|
AppSettings::DeriveDisplayOrder,
|
||||||
AppSettings::VersionlessSubcommands,
|
|
||||||
AppSettings::AllowExternalSubcommands,
|
AppSettings::AllowExternalSubcommands,
|
||||||
|
AppSettings::NoAutoVersion,
|
||||||
])
|
])
|
||||||
|
// 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
|
||||||
|
.global_setting(AppSettings::DisableColoredHelp)
|
||||||
.usage(usage)
|
.usage(usage)
|
||||||
.template(
|
.template(
|
||||||
"\
|
"\
|
||||||
|
@ -423,7 +426,7 @@ USAGE:
|
||||||
{usage}
|
{usage}
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
{unified}
|
{options}
|
||||||
|
|
||||||
Some common cargo commands are (see all commands with --list):
|
Some common cargo commands are (see all commands with --list):
|
||||||
build, b Compile the current package
|
build, b Compile the current package
|
||||||
|
@ -443,7 +446,7 @@ Some common cargo commands are (see all commands with --list):
|
||||||
|
|
||||||
See 'cargo help <command>' for more information on a specific command.\n",
|
See 'cargo help <command>' for more information on a specific command.\n",
|
||||||
)
|
)
|
||||||
.arg(opt("version", "Print version info and exit").short("V"))
|
.arg(opt("version", "Print version info and exit").short('V'))
|
||||||
.arg(opt("list", "List installed commands"))
|
.arg(opt("list", "List installed commands"))
|
||||||
.arg(opt("explain", "Run `rustc --explain CODE`").value_name("CODE"))
|
.arg(opt("explain", "Run `rustc --explain CODE`").value_name("CODE"))
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -451,8 +454,8 @@ See 'cargo help <command>' for more information on a specific command.\n",
|
||||||
"verbose",
|
"verbose",
|
||||||
"Use verbose output (-vv very verbose/build.rs output)",
|
"Use verbose output (-vv very verbose/build.rs output)",
|
||||||
)
|
)
|
||||||
.short("v")
|
.short('v')
|
||||||
.multiple(true)
|
.multiple_occurrences(true)
|
||||||
.global(true),
|
.global(true),
|
||||||
)
|
)
|
||||||
.arg_quiet()
|
.arg_quiet()
|
||||||
|
@ -475,7 +478,7 @@ See 'cargo help <command>' for more information on a specific command.\n",
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("unstable-features")
|
Arg::with_name("unstable-features")
|
||||||
.help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")
|
.help("Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")
|
||||||
.short("Z")
|
.short('Z')
|
||||||
.value_name("FLAG")
|
.value_name("FLAG")
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
|
@ -483,3 +486,8 @@ See 'cargo help <command>' for more information on a specific command.\n",
|
||||||
)
|
)
|
||||||
.subcommands(commands::builtin())
|
.subcommands(commands::builtin())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn verify_cli() {
|
||||||
|
cli().debug_assert();
|
||||||
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help bench` for more detailed information.\n")
|
.after_help("Run `cargo help bench` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
let mut compile_opts = args.compile_options(
|
let mut compile_opts = args.compile_options(
|
||||||
config,
|
config,
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help build` for more detailed information.\n")
|
.after_help("Run `cargo help build` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
let mut compile_opts = args.compile_options(
|
let mut compile_opts = args.compile_options(
|
||||||
config,
|
config,
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help check` for more detailed information.\n")
|
.after_help("Run `cargo help check` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
// This is a legacy behavior that causes `cargo check` to pass `--test`.
|
// This is a legacy behavior that causes `cargo check` to pass `--test`.
|
||||||
let test = matches!(args.value_of("profile"), Some("test"));
|
let test = matches!(args.value_of("profile"), Some("test"));
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help clean` for more detailed information.\n")
|
.after_help("Run `cargo help clean` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
|
|
||||||
if args.is_present_with_zero_values("package") {
|
if args.is_present_with_zero_values("package") {
|
||||||
|
|
|
@ -26,12 +26,12 @@ pub fn cli() -> App {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
config
|
config
|
||||||
.cli_unstable()
|
.cli_unstable()
|
||||||
.fail_if_stable_command(config, "config", 9301)?;
|
.fail_if_stable_command(config, "config", 9301)?;
|
||||||
match args.subcommand() {
|
match args.subcommand() {
|
||||||
("get", Some(args)) => {
|
Some(("get", args)) => {
|
||||||
let opts = cargo_config::GetOptions {
|
let opts = cargo_config::GetOptions {
|
||||||
key: args.value_of("key"),
|
key: args.value_of("key"),
|
||||||
format: args.value_of("format").unwrap().parse()?,
|
format: args.value_of("format").unwrap().parse()?,
|
||||||
|
@ -40,8 +40,11 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
||||||
};
|
};
|
||||||
cargo_config::get(config, &opts)?;
|
cargo_config::get(config, &opts)?;
|
||||||
}
|
}
|
||||||
(cmd, _) => {
|
Some((cmd, _)) => {
|
||||||
panic!("unexpected command `{}`", cmd)
|
unreachable!("unexpected command {}", cmd)
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
unreachable!("unexpected command")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help doc` for more detailed information.\n")
|
.after_help("Run `cargo help doc` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
let mode = CompileMode::Doc {
|
let mode = CompileMode::Doc {
|
||||||
deps: !args.is_present("no-deps"),
|
deps: !args.is_present("no-deps"),
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help fetch` for more detailed information.\n")
|
.after_help("Run `cargo help fetch` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
|
|
||||||
let opts = FetchOptions {
|
let opts = FetchOptions {
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help fix` for more detailed information.\n")
|
.after_help("Run `cargo help fix` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
// This is a legacy behavior that causes `cargo fix` to pass `--test`.
|
// This is a legacy behavior that causes `cargo fix` to pass `--test`.
|
||||||
let test = matches!(args.value_of("profile"), Some("test"));
|
let test = matches!(args.value_of("profile"), Some("test"));
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help generate-lockfile` for more detailed information.\n")
|
.after_help("Run `cargo help generate-lockfile` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
ops::generate_lockfile(&ws)?;
|
ops::generate_lockfile(&ws)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -9,6 +9,6 @@ pub fn cli() -> App {
|
||||||
.help(REMOVED)
|
.help(REMOVED)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(_config: &mut Config, _args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(_config: &mut Config, _args: &ArgMatches) -> CliResult {
|
||||||
Err(anyhow::format_err!(REMOVED).into())
|
Err(anyhow::format_err!(REMOVED).into())
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help init` for more detailed information.\n")
|
.after_help("Run `cargo help init` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let opts = args.new_options(config)?;
|
let opts = args.new_options(config)?;
|
||||||
let project_kind = ops::init(&opts, config)?;
|
let project_kind = ops::init(&opts, config)?;
|
||||||
config
|
config
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub fn cli() -> App {
|
||||||
"list all installed packages and their versions",
|
"list all installed packages and their versions",
|
||||||
))
|
))
|
||||||
.arg_jobs()
|
.arg_jobs()
|
||||||
.arg(opt("force", "Force overwriting existing crates or binaries").short("f"))
|
.arg(opt("force", "Force overwriting existing crates or binaries").short('f'))
|
||||||
.arg(opt("no-track", "Do not save tracking information"))
|
.arg(opt("no-track", "Do not save tracking information"))
|
||||||
.arg_features()
|
.arg_features()
|
||||||
.arg_profile("Install artifacts with the specified profile")
|
.arg_profile("Install artifacts with the specified profile")
|
||||||
|
@ -75,7 +75,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help install` for more detailed information.\n")
|
.after_help("Run `cargo help install` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
if let Some(path) = args.value_of_path("path", config) {
|
if let Some(path) = args.value_of_path("path", config) {
|
||||||
config.reload_rooted_at(path)?;
|
config.reload_rooted_at(path)?;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub struct ProjectLocation<'a> {
|
||||||
root: &'a str,
|
root: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let root_manifest;
|
let root_manifest;
|
||||||
let workspace;
|
let workspace;
|
||||||
let root = match WhatToFind::parse(args) {
|
let root = match WhatToFind::parse(args) {
|
||||||
|
@ -64,7 +64,7 @@ enum WhatToFind {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WhatToFind {
|
impl WhatToFind {
|
||||||
fn parse(args: &ArgMatches<'_>) -> Self {
|
fn parse(args: &ArgMatches) -> Self {
|
||||||
if args.is_present("workspace") {
|
if args.is_present("workspace") {
|
||||||
WhatToFind::Workspace
|
WhatToFind::Workspace
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,7 +79,7 @@ enum MessageFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MessageFormat {
|
impl MessageFormat {
|
||||||
fn parse(args: &ArgMatches<'_>) -> CargoResult<Self> {
|
fn parse(args: &ArgMatches) -> CargoResult<Self> {
|
||||||
let fmt = match args.value_of("message-format") {
|
let fmt = match args.value_of("message-format") {
|
||||||
Some(fmt) => fmt,
|
Some(fmt) => fmt,
|
||||||
None => return Ok(MessageFormat::Json),
|
None => return Ok(MessageFormat::Json),
|
||||||
|
|
|
@ -14,7 +14,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help login` for more detailed information.\n")
|
.after_help("Run `cargo help login` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
ops::registry_login(
|
ops::registry_login(
|
||||||
config,
|
config,
|
||||||
args.value_of("token").map(String::from),
|
args.value_of("token").map(String::from),
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help logout` for more detailed information.\n")
|
.after_help("Run `cargo help logout` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
if !config.cli_unstable().credential_process {
|
if !config.cli_unstable().credential_process {
|
||||||
config
|
config
|
||||||
.cli_unstable()
|
.cli_unstable()
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help metadata` for more detailed information.\n")
|
.after_help("Run `cargo help metadata` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
|
|
||||||
let version = match args.value_of("format-version") {
|
let version = match args.value_of("format-version") {
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub fn builtin() -> Vec<App> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches<'_>) -> CliResult> {
|
pub fn builtin_exec(cmd: &str) -> Option<fn(&mut Config, &ArgMatches) -> CliResult> {
|
||||||
let f = match cmd {
|
let f = match cmd {
|
||||||
"bench" => bench::exec,
|
"bench" => bench::exec,
|
||||||
"build" => build::exec,
|
"build" => build::exec,
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help new` for more detailed information.\n")
|
.after_help("Run `cargo help new` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let opts = args.new_options(config)?;
|
let opts = args.new_options(config)?;
|
||||||
|
|
||||||
ops::new(&opts, config)?;
|
ops::new(&opts, config)?;
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub fn cli() -> App {
|
||||||
"LOGIN",
|
"LOGIN",
|
||||||
"Name of a user or team to invite as an owner",
|
"Name of a user or team to invite as an owner",
|
||||||
)
|
)
|
||||||
.short("a"),
|
.short('a'),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
multi_opt(
|
multi_opt(
|
||||||
|
@ -21,16 +21,16 @@ pub fn cli() -> App {
|
||||||
"LOGIN",
|
"LOGIN",
|
||||||
"Name of a user or team to remove as an owner",
|
"Name of a user or team to remove as an owner",
|
||||||
)
|
)
|
||||||
.short("r"),
|
.short('r'),
|
||||||
)
|
)
|
||||||
.arg(opt("list", "List owners of a crate").short("l"))
|
.arg(opt("list", "List owners of a crate").short('l'))
|
||||||
.arg(opt("index", "Registry index to modify owners for").value_name("INDEX"))
|
.arg(opt("index", "Registry index to modify owners for").value_name("INDEX"))
|
||||||
.arg(opt("token", "API token to use when authenticating").value_name("TOKEN"))
|
.arg(opt("token", "API token to use when authenticating").value_name("TOKEN"))
|
||||||
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
|
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
|
||||||
.after_help("Run `cargo help owner` for more detailed information.\n")
|
.after_help("Run `cargo help owner` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
config.load_credentials()?;
|
config.load_credentials()?;
|
||||||
|
|
||||||
let registry = args.registry(config)?;
|
let registry = args.registry(config)?;
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub fn cli() -> App {
|
||||||
"list",
|
"list",
|
||||||
"Print files included in a package without making one",
|
"Print files included in a package without making one",
|
||||||
)
|
)
|
||||||
.short("l"),
|
.short('l'),
|
||||||
)
|
)
|
||||||
.arg(opt(
|
.arg(opt(
|
||||||
"no-verify",
|
"no-verify",
|
||||||
|
@ -38,7 +38,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help package` for more detailed information.\n")
|
.after_help("Run `cargo help package` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
let specs = args.packages_from_flags()?;
|
let specs = args.packages_from_flags()?;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help pkgid` for more detailed information.\n")
|
.after_help("Run `cargo help pkgid` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
if args.is_present_with_zero_values("package") {
|
if args.is_present_with_zero_values("package") {
|
||||||
print_available_packages(&ws)?
|
print_available_packages(&ws)?
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help publish` for more detailed information.\n")
|
.after_help("Run `cargo help publish` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
config.load_credentials()?;
|
config.load_credentials()?;
|
||||||
|
|
||||||
let registry = args.registry(config)?;
|
let registry = args.registry(config)?;
|
||||||
|
|
|
@ -13,7 +13,7 @@ Deprecated, use `cargo metadata --no-deps` instead.\
|
||||||
.arg_manifest_path()
|
.arg_manifest_path()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
config
|
config
|
||||||
.shell()
|
.shell()
|
||||||
|
|
|
@ -22,14 +22,19 @@ pub fn cli() -> App {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
match args.subcommand() {
|
match args.subcommand() {
|
||||||
("future-incompatibilities", Some(args)) => report_future_incompatibilies(config, args),
|
Some(("future-incompatibilities", args)) => report_future_incompatibilies(config, args),
|
||||||
(cmd, _) => panic!("unexpected command `{}`", cmd),
|
Some((cmd, _)) => {
|
||||||
|
unreachable!("unexpected command {}", cmd)
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
unreachable!("unexpected command")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_future_incompatibilies(config: &Config, args: &ArgMatches<'_>) -> CliResult {
|
fn report_future_incompatibilies(config: &Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
let reports = OnDiskReports::load(&ws)?;
|
let reports = OnDiskReports::load(&ws)?;
|
||||||
let id = args
|
let id = args
|
||||||
|
|
|
@ -11,7 +11,11 @@ pub fn cli() -> App {
|
||||||
.setting(AppSettings::TrailingVarArg)
|
.setting(AppSettings::TrailingVarArg)
|
||||||
.about("Run a binary or example of the local package")
|
.about("Run a binary or example of the local package")
|
||||||
.arg_quiet()
|
.arg_quiet()
|
||||||
.arg(Arg::with_name("args").multiple(true))
|
.arg(
|
||||||
|
Arg::with_name("args")
|
||||||
|
.allow_invalid_utf8(true)
|
||||||
|
.multiple(true),
|
||||||
|
)
|
||||||
.arg_targets_bin_example(
|
.arg_targets_bin_example(
|
||||||
"Name of the bin target to run",
|
"Name of the bin target to run",
|
||||||
"Name of the example target to run",
|
"Name of the example target to run",
|
||||||
|
@ -30,7 +34,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help run` for more detailed information.\n")
|
.after_help("Run `cargo help run` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
|
|
||||||
let mut compile_opts = args.compile_options(
|
let mut compile_opts = args.compile_options(
|
||||||
|
|
|
@ -50,7 +50,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help rustc` for more detailed information.\n")
|
.after_help("Run `cargo help rustc` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
// This is a legacy behavior that changes the behavior based on the profile.
|
// This is a legacy behavior that changes the behavior based on the profile.
|
||||||
// If we want to support this more formally, I think adding a --mode flag
|
// If we want to support this more formally, I think adding a --mode flag
|
||||||
|
|
|
@ -38,7 +38,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help rustdoc` for more detailed information.\n")
|
.after_help("Run `cargo help rustdoc` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
let mut compile_opts = args.compile_options_for_single_package(
|
let mut compile_opts = args.compile_options_for_single_package(
|
||||||
config,
|
config,
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help search` for more detailed information.\n")
|
.after_help("Run `cargo help search` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let registry = args.registry(config)?;
|
let registry = args.registry(config)?;
|
||||||
let index = args.index()?;
|
let index = args.index()?;
|
||||||
let limit = args.value_of_u32("limit")?;
|
let limit = args.value_of_u32("limit")?;
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn cli() -> App {
|
||||||
"quiet",
|
"quiet",
|
||||||
"Display one character per test instead of one line",
|
"Display one character per test instead of one line",
|
||||||
)
|
)
|
||||||
.short("q"),
|
.short('q'),
|
||||||
)
|
)
|
||||||
.arg_targets_all(
|
.arg_targets_all(
|
||||||
"Test only this package's library unit tests",
|
"Test only this package's library unit tests",
|
||||||
|
@ -62,7 +62,7 @@ pub fn cli() -> App {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
|
|
||||||
let mut compile_opts = args.compile_options(
|
let mut compile_opts = args.compile_options(
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub fn cli() -> App {
|
||||||
"Exclude specific workspace members",
|
"Exclude specific workspace members",
|
||||||
)
|
)
|
||||||
// Deprecated, use --no-dedupe instead.
|
// Deprecated, use --no-dedupe instead.
|
||||||
.arg(Arg::with_name("all").long("all").short("a").hidden(true))
|
.arg(Arg::with_name("all").long("all").short('a').hidden(true))
|
||||||
// Deprecated, use --target=all instead.
|
// Deprecated, use --target=all instead.
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("all-targets")
|
Arg::with_name("all-targets")
|
||||||
|
@ -46,7 +46,7 @@ pub fn cli() -> App {
|
||||||
(features, normal, build, dev, all, \
|
(features, normal, build, dev, all, \
|
||||||
no-normal, no-build, no-dev, no-proc-macro)",
|
no-normal, no-build, no-dev, no-proc-macro)",
|
||||||
)
|
)
|
||||||
.short("e"),
|
.short('e'),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
optional_multi_opt(
|
optional_multi_opt(
|
||||||
|
@ -54,7 +54,7 @@ pub fn cli() -> App {
|
||||||
"SPEC",
|
"SPEC",
|
||||||
"Invert the tree direction and focus on the given package",
|
"Invert the tree direction and focus on the given package",
|
||||||
)
|
)
|
||||||
.short("i"),
|
.short('i'),
|
||||||
)
|
)
|
||||||
.arg(multi_opt(
|
.arg(multi_opt(
|
||||||
"prune",
|
"prune",
|
||||||
|
@ -88,7 +88,7 @@ pub fn cli() -> App {
|
||||||
"duplicates",
|
"duplicates",
|
||||||
"Show only dependencies which come in multiple versions (implies -i)",
|
"Show only dependencies which come in multiple versions (implies -i)",
|
||||||
)
|
)
|
||||||
.short("d")
|
.short('d')
|
||||||
.alias("duplicate"),
|
.alias("duplicate"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -100,20 +100,20 @@ pub fn cli() -> App {
|
||||||
.arg(
|
.arg(
|
||||||
opt("format", "Format string used for printing dependencies")
|
opt("format", "Format string used for printing dependencies")
|
||||||
.value_name("FORMAT")
|
.value_name("FORMAT")
|
||||||
.short("f")
|
.short('f')
|
||||||
.default_value("{p}"),
|
.default_value("{p}"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
// Backwards compatibility with old cargo-tree.
|
// Backwards compatibility with old cargo-tree.
|
||||||
Arg::with_name("version")
|
Arg::with_name("version")
|
||||||
.long("version")
|
.long("version")
|
||||||
.short("V")
|
.short('V')
|
||||||
.hidden(true),
|
.hidden(true),
|
||||||
)
|
)
|
||||||
.after_help("Run `cargo help tree` for more detailed information.\n")
|
.after_help("Run `cargo help tree` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
if args.is_present("version") {
|
if args.is_present("version") {
|
||||||
let verbose = args.occurrences_of("verbose") > 0;
|
let verbose = args.occurrences_of("verbose") > 0;
|
||||||
let version = cli::get_version_string(verbose);
|
let version = cli::get_version_string(verbose);
|
||||||
|
@ -226,10 +226,7 @@ subtree of the package given to -p.\n\
|
||||||
/// Parses `--edges` option.
|
/// Parses `--edges` option.
|
||||||
///
|
///
|
||||||
/// Returns a tuple of `EdgeKind` map and `no_proc_marco` flag.
|
/// Returns a tuple of `EdgeKind` map and `no_proc_marco` flag.
|
||||||
fn parse_edge_kinds(
|
fn parse_edge_kinds(config: &Config, args: &ArgMatches) -> CargoResult<(HashSet<EdgeKind>, bool)> {
|
||||||
config: &Config,
|
|
||||||
args: &ArgMatches<'_>,
|
|
||||||
) -> CargoResult<(HashSet<EdgeKind>, bool)> {
|
|
||||||
let (kinds, no_proc_macro) = {
|
let (kinds, no_proc_macro) = {
|
||||||
let mut no_proc_macro = false;
|
let mut no_proc_macro = false;
|
||||||
let mut kinds = args.values_of("edges").map_or_else(
|
let mut kinds = args.values_of("edges").map_or_else(
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help uninstall` for more detailed information.\n")
|
.after_help("Run `cargo help uninstall` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let root = args.value_of("root");
|
let root = args.value_of("root");
|
||||||
|
|
||||||
if args.is_present_with_zero_values("package") {
|
if args.is_present_with_zero_values("package") {
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub fn cli() -> App {
|
||||||
subcommand("update")
|
subcommand("update")
|
||||||
.about("Update dependencies as recorded in the local lock file")
|
.about("Update dependencies as recorded in the local lock file")
|
||||||
.arg_quiet()
|
.arg_quiet()
|
||||||
.arg(opt("workspace", "Only update the workspace packages").short("w"))
|
.arg(opt("workspace", "Only update the workspace packages").short('w'))
|
||||||
.arg_package_spec_simple("Package to update")
|
.arg_package_spec_simple("Package to update")
|
||||||
.arg(opt(
|
.arg(opt(
|
||||||
"aggressive",
|
"aggressive",
|
||||||
|
@ -25,7 +25,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help update` for more detailed information.\n")
|
.after_help("Run `cargo help update` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let ws = args.workspace(config)?;
|
let ws = args.workspace(config)?;
|
||||||
|
|
||||||
if args.is_present_with_zero_values("package") {
|
if args.is_present_with_zero_values("package") {
|
||||||
|
|
|
@ -7,7 +7,11 @@ pub fn cli() -> App {
|
||||||
.about("Vendor all dependencies for a project locally")
|
.about("Vendor all dependencies for a project locally")
|
||||||
.arg_quiet()
|
.arg_quiet()
|
||||||
.arg_manifest_path()
|
.arg_manifest_path()
|
||||||
.arg(Arg::with_name("path").help("Where to vendor crates (`vendor` by default)"))
|
.arg(
|
||||||
|
Arg::with_name("path")
|
||||||
|
.allow_invalid_utf8(true)
|
||||||
|
.help("Where to vendor crates (`vendor` by default)"),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("no-delete")
|
Arg::with_name("no-delete")
|
||||||
.long("no-delete")
|
.long("no-delete")
|
||||||
|
@ -15,17 +19,18 @@ pub fn cli() -> App {
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("tomls")
|
Arg::with_name("tomls")
|
||||||
.short("s")
|
.short('s')
|
||||||
.long("sync")
|
.long("sync")
|
||||||
.help("Additional `Cargo.toml` to sync and vendor")
|
.help("Additional `Cargo.toml` to sync and vendor")
|
||||||
.value_name("TOML")
|
.value_name("TOML")
|
||||||
|
.allow_invalid_utf8(true)
|
||||||
.multiple(true),
|
.multiple(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("respect-source-config")
|
Arg::with_name("respect-source-config")
|
||||||
.long("respect-source-config")
|
.long("respect-source-config")
|
||||||
.help("Respect `[source]` config in `.cargo/config`")
|
.help("Respect `[source]` config in `.cargo/config`")
|
||||||
.multiple(true),
|
.multiple_occurrences(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("versioned-dirs")
|
Arg::with_name("versioned-dirs")
|
||||||
|
@ -59,7 +64,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help vendor` for more detailed information.\n")
|
.after_help("Run `cargo help vendor` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
// We're doing the vendoring operation ourselves, so we don't actually want
|
// We're doing the vendoring operation ourselves, so we don't actually want
|
||||||
// to respect any of the `source` configuration in Cargo itself. That's
|
// to respect any of the `source` configuration in Cargo itself. That's
|
||||||
// intended for other consumers of Cargo, but we want to go straight to the
|
// intended for other consumers of Cargo, but we want to go straight to the
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help verify-project` for more detailed information.\n")
|
.after_help("Run `cargo help verify-project` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
if let Err(e) = args.workspace(config) {
|
if let Err(e) = args.workspace(config) {
|
||||||
let mut h = HashMap::new();
|
let mut h = HashMap::new();
|
||||||
h.insert("invalid".to_string(), e.to_string());
|
h.insert("invalid".to_string(), e.to_string());
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help version` for more detailed information.\n")
|
.after_help("Run `cargo help version` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
let verbose = args.occurrences_of("verbose") > 0;
|
let verbose = args.occurrences_of("verbose") > 0;
|
||||||
let version = cli::get_version_string(verbose);
|
let version = cli::get_version_string(verbose);
|
||||||
cargo::drop_print!(config, "{}", version);
|
cargo::drop_print!(config, "{}", version);
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn cli() -> App {
|
||||||
.after_help("Run `cargo help yank` for more detailed information.\n")
|
.after_help("Run `cargo help yank` for more detailed information.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
|
||||||
config.load_credentials()?;
|
config.load_credentials()?;
|
||||||
|
|
||||||
let registry = args.registry(config)?;
|
let registry = args.registry(config)?;
|
||||||
|
|
|
@ -116,7 +116,7 @@ fn list_commands(config: &Config) -> BTreeMap<String, CommandInfo> {
|
||||||
commands.insert(
|
commands.insert(
|
||||||
cmd.get_name().to_string(),
|
cmd.get_name().to_string(),
|
||||||
CommandInfo::BuiltIn {
|
CommandInfo::BuiltIn {
|
||||||
about: cmd.p.meta.about.map(|s| s.to_string()),
|
about: cmd.get_about().map(|s| s.to_string()),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,12 @@ mod version;
|
||||||
|
|
||||||
pub fn exit_with_error(err: CliError, shell: &mut Shell) -> ! {
|
pub fn exit_with_error(err: CliError, shell: &mut Shell) -> ! {
|
||||||
debug!("exit_with_error; err={:?}", err);
|
debug!("exit_with_error; err={:?}", err);
|
||||||
|
|
||||||
if let Some(ref err) = err.error {
|
if let Some(ref err) = err.error {
|
||||||
if let Some(clap_err) = err.downcast_ref::<clap::Error>() {
|
if let Some(clap_err) = err.downcast_ref::<clap::Error>() {
|
||||||
clap_err.exit()
|
let exit_code = if clap_err.use_stderr() { 1 } else { 0 };
|
||||||
|
let _ = clap_err.print();
|
||||||
|
std::process::exit(exit_code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(deprecated)]
|
||||||
|
|
||||||
use crate::core::compiler::{BuildConfig, MessageFormat};
|
use crate::core::compiler::{BuildConfig, MessageFormat};
|
||||||
use crate::core::resolver::CliFeatures;
|
use crate::core::resolver::CliFeatures;
|
||||||
use crate::core::{Edition, Workspace};
|
use crate::core::{Edition, Workspace};
|
||||||
|
@ -23,10 +25,10 @@ pub use crate::core::compiler::CompileMode;
|
||||||
pub use crate::{CliError, CliResult, Config};
|
pub use crate::{CliError, CliResult, Config};
|
||||||
pub use clap::{AppSettings, Arg, ArgMatches};
|
pub use clap::{AppSettings, Arg, ArgMatches};
|
||||||
|
|
||||||
pub type App = clap::App<'static, 'static>;
|
pub type App = clap::App<'static>;
|
||||||
|
|
||||||
pub trait AppExt: Sized {
|
pub trait AppExt: Sized {
|
||||||
fn _arg(self, arg: Arg<'static, 'static>) -> Self;
|
fn _arg(self, arg: Arg<'static>) -> Self;
|
||||||
|
|
||||||
/// Do not use this method, it is only for backwards compatibility.
|
/// Do not use this method, it is only for backwards compatibility.
|
||||||
/// Use `arg_package_spec_no_all` instead.
|
/// Use `arg_package_spec_no_all` instead.
|
||||||
|
@ -55,13 +57,13 @@ pub trait AppExt: Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_package_spec_simple(self, package: &'static str) -> Self {
|
fn arg_package_spec_simple(self, package: &'static str) -> Self {
|
||||||
self._arg(optional_multi_opt("package", "SPEC", package).short("p"))
|
self._arg(optional_multi_opt("package", "SPEC", package).short('p'))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_package(self, package: &'static str) -> Self {
|
fn arg_package(self, package: &'static str) -> Self {
|
||||||
self._arg(
|
self._arg(
|
||||||
optional_opt("package", package)
|
optional_opt("package", package)
|
||||||
.short("p")
|
.short('p')
|
||||||
.value_name("SPEC"),
|
.value_name("SPEC"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -69,7 +71,7 @@ pub trait AppExt: Sized {
|
||||||
fn arg_jobs(self) -> Self {
|
fn arg_jobs(self) -> Self {
|
||||||
self._arg(
|
self._arg(
|
||||||
opt("jobs", "Number of parallel jobs, defaults to # of CPUs")
|
opt("jobs", "Number of parallel jobs, defaults to # of CPUs")
|
||||||
.short("j")
|
.short('j')
|
||||||
.value_name("N"),
|
.value_name("N"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -142,7 +144,7 @@ pub trait AppExt: Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_release(self, release: &'static str) -> Self {
|
fn arg_release(self, release: &'static str) -> Self {
|
||||||
self._arg(opt("release", release).short("r"))
|
self._arg(opt("release", release).short('r'))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_profile(self, profile: &'static str) -> Self {
|
fn arg_profile(self, profile: &'static str) -> Self {
|
||||||
|
@ -238,21 +240,21 @@ pub trait AppExt: Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_quiet(self) -> Self {
|
fn arg_quiet(self) -> Self {
|
||||||
self._arg(opt("quiet", "Do not print cargo log messages").short("q"))
|
self._arg(opt("quiet", "Do not print cargo log messages").short('q'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppExt for App {
|
impl AppExt for App {
|
||||||
fn _arg(self, arg: Arg<'static, 'static>) -> Self {
|
fn _arg(self, arg: Arg<'static>) -> Self {
|
||||||
self.arg(arg)
|
self.arg(arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn opt(name: &'static str, help: &'static str) -> Arg<'static, 'static> {
|
pub fn opt(name: &'static str, help: &'static str) -> Arg<'static> {
|
||||||
Arg::with_name(name).long(name).help(help)
|
Arg::with_name(name).long(name).help(help)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn optional_opt(name: &'static str, help: &'static str) -> Arg<'static, 'static> {
|
pub fn optional_opt(name: &'static str, help: &'static str) -> Arg<'static> {
|
||||||
opt(name, help).min_values(0)
|
opt(name, help).min_values(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +262,7 @@ pub fn optional_multi_opt(
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
value_name: &'static str,
|
value_name: &'static str,
|
||||||
help: &'static str,
|
help: &'static str,
|
||||||
) -> Arg<'static, 'static> {
|
) -> Arg<'static> {
|
||||||
opt(name, help)
|
opt(name, help)
|
||||||
.value_name(value_name)
|
.value_name(value_name)
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
|
@ -268,11 +270,7 @@ pub fn optional_multi_opt(
|
||||||
.number_of_values(1)
|
.number_of_values(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn multi_opt(
|
pub fn multi_opt(name: &'static str, value_name: &'static str, help: &'static str) -> Arg<'static> {
|
||||||
name: &'static str,
|
|
||||||
value_name: &'static str,
|
|
||||||
help: &'static str,
|
|
||||||
) -> Arg<'static, 'static> {
|
|
||||||
// Note that all `.multiple(true)` arguments in Cargo should specify
|
// Note that all `.multiple(true)` arguments in Cargo should specify
|
||||||
// `.number_of_values(1)` as well, so that `--foo val1 val2` is
|
// `.number_of_values(1)` as well, so that `--foo val1 val2` is
|
||||||
// *not* parsed as `foo` with values ["val1", "val2"].
|
// *not* parsed as `foo` with values ["val1", "val2"].
|
||||||
|
@ -308,7 +306,10 @@ pub trait ArgMatchesExt {
|
||||||
let arg = match self._value_of(name) {
|
let arg = match self._value_of(name) {
|
||||||
None => None,
|
None => None,
|
||||||
Some(arg) => Some(arg.parse::<u32>().map_err(|_| {
|
Some(arg) => Some(arg.parse::<u32>().map_err(|_| {
|
||||||
clap::Error::value_validation_auto(format!("could not parse `{}` as a number", arg))
|
clap::Error::raw(
|
||||||
|
clap::ErrorKind::ValueValidation,
|
||||||
|
format!("Invalid value: could not parse `{}` as a number", arg),
|
||||||
|
)
|
||||||
})?),
|
})?),
|
||||||
};
|
};
|
||||||
Ok(arg)
|
Ok(arg)
|
||||||
|
@ -320,7 +321,11 @@ pub trait ArgMatchesExt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn root_manifest(&self, config: &Config) -> CargoResult<PathBuf> {
|
fn root_manifest(&self, config: &Config) -> CargoResult<PathBuf> {
|
||||||
if let Some(path) = self.value_of_path("manifest-path", config) {
|
if let Some(path) = self
|
||||||
|
._is_valid_arg("manifest-path")
|
||||||
|
.then(|| self.value_of_path("manifest-path", config))
|
||||||
|
.flatten()
|
||||||
|
{
|
||||||
// In general, we try to avoid normalizing paths in Cargo,
|
// In general, we try to avoid normalizing paths in Cargo,
|
||||||
// but in this particular case we need it to fix #3586.
|
// but in this particular case we need it to fix #3586.
|
||||||
let path = paths::normalize_path(&path);
|
let path = paths::normalize_path(&path);
|
||||||
|
@ -395,8 +400,8 @@ pub trait ArgMatchesExt {
|
||||||
};
|
};
|
||||||
|
|
||||||
let name = match (
|
let name = match (
|
||||||
self._is_present("release"),
|
self.is_valid_and_present("release"),
|
||||||
self._is_present("debug"),
|
self.is_valid_and_present("debug"),
|
||||||
specified_profile,
|
specified_profile,
|
||||||
) {
|
) {
|
||||||
(false, false, None) => default,
|
(false, false, None) => default,
|
||||||
|
@ -424,9 +429,13 @@ pub trait ArgMatchesExt {
|
||||||
fn packages_from_flags(&self) -> CargoResult<Packages> {
|
fn packages_from_flags(&self) -> CargoResult<Packages> {
|
||||||
Packages::from_flags(
|
Packages::from_flags(
|
||||||
// TODO Integrate into 'workspace'
|
// TODO Integrate into 'workspace'
|
||||||
self._is_present("workspace") || self._is_present("all"),
|
self.is_valid_and_present("workspace") || self.is_valid_and_present("all"),
|
||||||
self._values_of("exclude"),
|
self._is_valid_arg("exclude")
|
||||||
self._values_of("package"),
|
.then(|| self._values_of("exclude"))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
self._is_valid_arg("package")
|
||||||
|
.then(|| self._values_of("package"))
|
||||||
|
.unwrap_or_default(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,9 +512,9 @@ pub trait ArgMatchesExt {
|
||||||
let mut build_config = BuildConfig::new(config, self.jobs()?, &self.targets(), mode)?;
|
let mut build_config = BuildConfig::new(config, self.jobs()?, &self.targets(), mode)?;
|
||||||
build_config.message_format = message_format.unwrap_or(MessageFormat::Human);
|
build_config.message_format = message_format.unwrap_or(MessageFormat::Human);
|
||||||
build_config.requested_profile = self.get_profile_name(config, "dev", profile_checking)?;
|
build_config.requested_profile = self.get_profile_name(config, "dev", profile_checking)?;
|
||||||
build_config.build_plan = self._is_present("build-plan");
|
build_config.build_plan = self.is_valid_and_present("build-plan");
|
||||||
build_config.unit_graph = self._is_present("unit-graph");
|
build_config.unit_graph = self.is_valid_and_present("unit-graph");
|
||||||
build_config.future_incompat_report = self._is_present("future-incompat-report");
|
build_config.future_incompat_report = self.is_valid_and_present("future-incompat-report");
|
||||||
if build_config.build_plan {
|
if build_config.build_plan {
|
||||||
config
|
config
|
||||||
.cli_unstable()
|
.cli_unstable()
|
||||||
|
@ -522,28 +531,32 @@ pub trait ArgMatchesExt {
|
||||||
cli_features: self.cli_features()?,
|
cli_features: self.cli_features()?,
|
||||||
spec,
|
spec,
|
||||||
filter: CompileFilter::from_raw_arguments(
|
filter: CompileFilter::from_raw_arguments(
|
||||||
self._is_present("lib"),
|
self.is_valid_and_present("lib"),
|
||||||
self._values_of("bin"),
|
self._values_of("bin"),
|
||||||
self._is_present("bins"),
|
self.is_valid_and_present("bins"),
|
||||||
self._values_of("test"),
|
self._is_valid_arg("test")
|
||||||
self._is_present("tests"),
|
.then(|| self._values_of("test"))
|
||||||
|
.unwrap_or_default(),
|
||||||
|
self.is_valid_and_present("tests"),
|
||||||
self._values_of("example"),
|
self._values_of("example"),
|
||||||
self._is_present("examples"),
|
self.is_valid_and_present("examples"),
|
||||||
self._values_of("bench"),
|
self._is_valid_arg("bench")
|
||||||
self._is_present("benches"),
|
.then(|| self._values_of("bench"))
|
||||||
self._is_present("all-targets"),
|
.unwrap_or_default(),
|
||||||
|
self.is_valid_and_present("benches"),
|
||||||
|
self.is_valid_and_present("all-targets"),
|
||||||
),
|
),
|
||||||
target_rustdoc_args: None,
|
target_rustdoc_args: None,
|
||||||
target_rustc_args: None,
|
target_rustc_args: None,
|
||||||
target_rustc_crate_types: None,
|
target_rustc_crate_types: None,
|
||||||
local_rustdoc_args: None,
|
local_rustdoc_args: None,
|
||||||
rustdoc_document_private_items: false,
|
rustdoc_document_private_items: false,
|
||||||
honor_rust_version: !self._is_present("ignore-rust-version"),
|
honor_rust_version: !self.is_valid_and_present("ignore-rust-version"),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(ws) = workspace {
|
if let Some(ws) = workspace {
|
||||||
self.check_optional_opts(ws, &opts)?;
|
self.check_optional_opts(ws, &opts)?;
|
||||||
} else if self.is_present_with_zero_values("package") {
|
} else if self._is_valid_arg("package") && self.is_present_with_zero_values("package") {
|
||||||
// As for cargo 0.50.0, this won't occur but if someone sneaks in
|
// As for cargo 0.50.0, this won't occur but if someone sneaks in
|
||||||
// we can still provide this informative message for them.
|
// we can still provide this informative message for them.
|
||||||
anyhow::bail!(
|
anyhow::bail!(
|
||||||
|
@ -630,7 +643,7 @@ pub trait ArgMatchesExt {
|
||||||
workspace: &Workspace<'_>,
|
workspace: &Workspace<'_>,
|
||||||
compile_opts: &CompileOptions,
|
compile_opts: &CompileOptions,
|
||||||
) -> CargoResult<()> {
|
) -> CargoResult<()> {
|
||||||
if self.is_present_with_zero_values("package") {
|
if self._is_valid_arg("package") && self.is_present_with_zero_values("package") {
|
||||||
print_available_packages(workspace)?
|
print_available_packages(workspace)?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,11 +655,11 @@ pub trait ArgMatchesExt {
|
||||||
print_available_binaries(workspace, compile_opts)?;
|
print_available_binaries(workspace, compile_opts)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_present_with_zero_values("bench") {
|
if self._is_valid_arg("bench") && self.is_present_with_zero_values("bench") {
|
||||||
print_available_benches(workspace, compile_opts)?;
|
print_available_benches(workspace, compile_opts)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_present_with_zero_values("test") {
|
if self._is_valid_arg("test") && self.is_present_with_zero_values("test") {
|
||||||
print_available_tests(workspace, compile_opts)?;
|
print_available_tests(workspace, compile_opts)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,6 +670,10 @@ pub trait ArgMatchesExt {
|
||||||
self._is_present(name) && self._value_of(name).is_none()
|
self._is_present(name) && self._value_of(name).is_none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_valid_and_present(&self, name: &str) -> bool {
|
||||||
|
self._is_valid_arg(name) && self._is_present(name)
|
||||||
|
}
|
||||||
|
|
||||||
fn _value_of(&self, name: &str) -> Option<&str>;
|
fn _value_of(&self, name: &str) -> Option<&str>;
|
||||||
|
|
||||||
fn _values_of(&self, name: &str) -> Vec<String>;
|
fn _values_of(&self, name: &str) -> Vec<String>;
|
||||||
|
@ -666,9 +683,11 @@ pub trait ArgMatchesExt {
|
||||||
fn _values_of_os(&self, name: &str) -> Vec<OsString>;
|
fn _values_of_os(&self, name: &str) -> Vec<OsString>;
|
||||||
|
|
||||||
fn _is_present(&self, name: &str) -> bool;
|
fn _is_present(&self, name: &str) -> bool;
|
||||||
|
|
||||||
|
fn _is_valid_arg(&self, name: &str) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ArgMatchesExt for ArgMatches<'a> {
|
impl<'a> ArgMatchesExt for ArgMatches {
|
||||||
fn _value_of(&self, name: &str) -> Option<&str> {
|
fn _value_of(&self, name: &str) -> Option<&str> {
|
||||||
self.value_of(name)
|
self.value_of(name)
|
||||||
}
|
}
|
||||||
|
@ -694,13 +713,17 @@ impl<'a> ArgMatchesExt for ArgMatches<'a> {
|
||||||
fn _is_present(&self, name: &str) -> bool {
|
fn _is_present(&self, name: &str) -> bool {
|
||||||
self.is_present(name)
|
self.is_present(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn _is_valid_arg(&self, name: &str) -> bool {
|
||||||
|
self.is_valid_arg(name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn values(args: &ArgMatches<'_>, name: &str) -> Vec<String> {
|
pub fn values(args: &ArgMatches, name: &str) -> Vec<String> {
|
||||||
args._values_of(name)
|
args._values_of(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn values_os(args: &ArgMatches<'_>, name: &str) -> Vec<OsString> {
|
pub fn values_os(args: &ArgMatches, name: &str) -> Vec<OsString> {
|
||||||
args._values_of_os(name)
|
args._values_of_os(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -300,6 +300,12 @@ impl From<clap::Error> for CliError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<std::io::Error> for CliError {
|
||||||
|
fn from(err: std::io::Error) -> CliError {
|
||||||
|
CliError::new(err.into(), 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Construction helpers
|
// Construction helpers
|
||||||
|
|
||||||
|
|
|
@ -473,22 +473,20 @@ fn includes() {
|
||||||
.with_stderr("")
|
.with_stderr("")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
cargo_process(
|
cargo_process("config get build.rustflags --show-origin -Zunstable-options -Zconfig-include")
|
||||||
"config get build.rustflags --show-origin=yes -Zunstable-options -Zconfig-include",
|
.cwd(&sub_folder.parent().unwrap())
|
||||||
)
|
.masquerade_as_nightly_cargo()
|
||||||
.cwd(&sub_folder.parent().unwrap())
|
.with_stdout(
|
||||||
.masquerade_as_nightly_cargo()
|
"\
|
||||||
.with_stdout(
|
|
||||||
"\
|
|
||||||
build.rustflags = [
|
build.rustflags = [
|
||||||
\"--flag-other\", # [ROOT]/foo/.cargo/other.toml
|
\"--flag-other\", # [ROOT]/foo/.cargo/other.toml
|
||||||
\"--flag-directory\", # [ROOT]/foo/.cargo/config.toml
|
\"--flag-directory\", # [ROOT]/foo/.cargo/config.toml
|
||||||
\"--flag-global\", # [ROOT]/home/.cargo/config.toml
|
\"--flag-global\", # [ROOT]/home/.cargo/config.toml
|
||||||
]
|
]
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.with_stderr("")
|
.with_stderr("")
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
cargo_process("config get --merged=no -Zunstable-options -Zconfig-include")
|
cargo_process("config get --merged=no -Zunstable-options -Zconfig-include")
|
||||||
.cwd(&sub_folder.parent().unwrap())
|
.cwd(&sub_folder.parent().unwrap())
|
||||||
|
|
|
@ -1183,7 +1183,7 @@ fn cargo_metadata_bad_version() {
|
||||||
.with_status(1)
|
.with_status(1)
|
||||||
.with_stderr_contains(
|
.with_stderr_contains(
|
||||||
"\
|
"\
|
||||||
error: '2' isn't a valid value for '--format-version <VERSION>'
|
error: \"2\" isn't a valid value for '--format-version <VERSION>'
|
||||||
<tab>[possible values: 1]
|
<tab>[possible values: 1]
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
|
|
|
@ -362,7 +362,7 @@ fn new_default_edition() {
|
||||||
#[cargo_test]
|
#[cargo_test]
|
||||||
fn new_with_bad_edition() {
|
fn new_with_bad_edition() {
|
||||||
cargo_process("new --edition something_else foo")
|
cargo_process("new --edition something_else foo")
|
||||||
.with_stderr_contains("error: 'something_else' isn't a valid value[..]")
|
.with_stderr_contains("error: \"something_else\" isn't a valid value[..]")
|
||||||
.with_status(1)
|
.with_status(1)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1251,7 +1251,7 @@ fn run_multiple_packages() {
|
||||||
|
|
||||||
cargo().arg("-p").arg("d1").arg("-p").arg("d2")
|
cargo().arg("-p").arg("d1").arg("-p").arg("d2")
|
||||||
.with_status(1)
|
.with_status(1)
|
||||||
.with_stderr_contains("error: The argument '--package <SPEC>' was provided more than once, but cannot be used multiple times").run();
|
.with_stderr_contains("error: The argument '--package <SPEC>...' was provided more than once, but cannot be used multiple times").run();
|
||||||
|
|
||||||
cargo()
|
cargo()
|
||||||
.arg("-p")
|
.arg("-p")
|
||||||
|
|
|
@ -540,7 +540,7 @@ fn fail_with_multiple_packages() {
|
||||||
.with_status(1)
|
.with_status(1)
|
||||||
.with_stderr_contains(
|
.with_stderr_contains(
|
||||||
"\
|
"\
|
||||||
error: The argument '--package <SPEC>' was provided more than once, \
|
error: The argument '--package <SPEC>...' was provided more than once, \
|
||||||
but cannot be used multiple times
|
but cannot be used multiple times
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue