mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
refactor(cli): Align the two run's params
This commit is contained in:
parent
2bd9f144f8
commit
c421e0bf3a
@ -412,13 +412,6 @@ fn execute_subcommand(config: &mut Config, cmd: &str, subcommand_args: &ArgMatch
|
|||||||
return exec(config, subcommand_args);
|
return exec(config, subcommand_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ext_args: Vec<&OsStr> = vec![OsStr::new(cmd)];
|
|
||||||
ext_args.extend(
|
|
||||||
subcommand_args
|
|
||||||
.get_many::<OsString>("")
|
|
||||||
.unwrap_or_default()
|
|
||||||
.map(OsString::as_os_str),
|
|
||||||
);
|
|
||||||
if commands::run::is_manifest_command(cmd) {
|
if commands::run::is_manifest_command(cmd) {
|
||||||
let ext_path = super::find_external_subcommand(config, cmd);
|
let ext_path = super::find_external_subcommand(config, cmd);
|
||||||
if !config.cli_unstable().script && ext_path.is_some() {
|
if !config.cli_unstable().script && ext_path.is_some() {
|
||||||
@ -428,11 +421,30 @@ external subcommand `{cmd}` has the appearance of a manfiest-command
|
|||||||
This was previously accepted but will be phased out when `-Zscript` is stabilized.
|
This was previously accepted but will be phased out when `-Zscript` is stabilized.
|
||||||
For more information, see issue #12207 <https://github.com/rust-lang/cargo/issues/12207>.",
|
For more information, see issue #12207 <https://github.com/rust-lang/cargo/issues/12207>.",
|
||||||
))?;
|
))?;
|
||||||
|
let mut ext_args = vec![OsStr::new(cmd)];
|
||||||
|
ext_args.extend(
|
||||||
|
subcommand_args
|
||||||
|
.get_many::<OsString>("")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.map(OsString::as_os_str),
|
||||||
|
);
|
||||||
super::execute_external_subcommand(config, cmd, &ext_args)
|
super::execute_external_subcommand(config, cmd, &ext_args)
|
||||||
} else {
|
} else {
|
||||||
|
let ext_args: Vec<OsString> = subcommand_args
|
||||||
|
.get_many::<OsString>("")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.cloned()
|
||||||
|
.collect();
|
||||||
commands::run::exec_manifest_command(config, cmd, &ext_args)
|
commands::run::exec_manifest_command(config, cmd, &ext_args)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
let mut ext_args = vec![OsStr::new(cmd)];
|
||||||
|
ext_args.extend(
|
||||||
|
subcommand_args
|
||||||
|
.get_many::<OsString>("")
|
||||||
|
.unwrap_or_default()
|
||||||
|
.map(OsString::as_os_str),
|
||||||
|
);
|
||||||
super::execute_external_subcommand(config, cmd, &ext_args)
|
super::execute_external_subcommand(config, cmd, &ext_args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ pub fn is_manifest_command(arg: &str) -> bool {
|
|||||||
1 < path.components().count() || path.extension() == Some(OsStr::new("rs"))
|
1 < path.components().count() || path.extension() == Some(OsStr::new("rs"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec_manifest_command(config: &Config, cmd: &str, _args: &[&OsStr]) -> CliResult {
|
pub fn exec_manifest_command(config: &Config, cmd: &str, _args: &[OsString]) -> CliResult {
|
||||||
if !config.cli_unstable().script {
|
if !config.cli_unstable().script {
|
||||||
return Err(anyhow::anyhow!("running `{cmd}` requires `-Zscript`").into());
|
return Err(anyhow::anyhow!("running `{cmd}` requires `-Zscript`").into());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user