mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Support external subcommands
This commit is contained in:
parent
8b4f06cbb6
commit
81ce3e1bef
@ -223,8 +223,8 @@ fn execute(flags: Flags, config: &mut Config) -> CliResult {
|
|||||||
}
|
}
|
||||||
None => args,
|
None => args,
|
||||||
};
|
};
|
||||||
|
unimplemented!()
|
||||||
execute_external_subcommand(config, &args[1], &args)
|
// execute_external_subcommand(config, &args[1], &args)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_execute_builtin_command(config: &mut Config, args: &[String]) -> Option<CliResult> {
|
fn try_execute_builtin_command(config: &mut Config, args: &[String]) -> Option<CliResult> {
|
||||||
@ -283,7 +283,7 @@ fn find_closest(config: &Config, cmd: &str) -> Option<String> {
|
|||||||
filtered.get(0).map(|slot| slot.1.clone())
|
filtered.get(0).map(|slot| slot.1.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execute_external_subcommand(config: &Config, cmd: &str, args: &[String]) -> CliResult {
|
fn execute_external_subcommand(config: &Config, cmd: &str, args: &[&str]) -> CliResult {
|
||||||
let command_exe = format!("cargo-{}{}", cmd, env::consts::EXE_SUFFIX);
|
let command_exe = format!("cargo-{}{}", cmd, env::consts::EXE_SUFFIX);
|
||||||
let path = search_directories(config)
|
let path = search_directories(config)
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -506,6 +506,11 @@ pub fn do_main(config: &mut Config) -> Result<(), CliError> {
|
|||||||
registry)?;
|
registry)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
(external, Some(args)) => {
|
||||||
|
let mut ext_args: Vec<&str> = vec![external];
|
||||||
|
ext_args.extend(args.values_of("").unwrap_or_default());
|
||||||
|
super::execute_external_subcommand(config, external, &ext_args)
|
||||||
|
}
|
||||||
_ => Ok(())
|
_ => Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,6 +523,7 @@ fn cli() -> App {
|
|||||||
AppSettings::UnifiedHelpMessage,
|
AppSettings::UnifiedHelpMessage,
|
||||||
AppSettings::DeriveDisplayOrder,
|
AppSettings::DeriveDisplayOrder,
|
||||||
AppSettings::VersionlessSubcommands,
|
AppSettings::VersionlessSubcommands,
|
||||||
|
AppSettings::AllowExternalSubcommands,
|
||||||
])
|
])
|
||||||
.about("Rust's package manager")
|
.about("Rust's package manager")
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -164,7 +164,6 @@ fn override_cargo_home() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
|
||||||
fn cargo_subcommand_env() {
|
fn cargo_subcommand_env() {
|
||||||
use cargotest::support::cargo_exe;
|
use cargotest::support::cargo_exe;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user