mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Merge pull request #1227 from kbknapp/v3-dev
fix(Suggestions): disables suggestions when AllowExternalSubcommand i…
This commit is contained in:
commit
564f63640c
2 changed files with 19 additions and 1 deletions
|
@ -472,7 +472,7 @@ where
|
|||
}
|
||||
|
||||
if !(self.is_set(AS::ArgsNegateSubcommands) && self.is_set(AS::ValidArgFound))
|
||||
&& !self.is_set(AS::InferSubcommands)
|
||||
&& !self.is_set(AS::InferSubcommands) && !self.is_set(AS::AllowExternalSubcommands)
|
||||
{
|
||||
if let Some(cdate) =
|
||||
suggestions::did_you_mean(&*arg_os.to_string_lossy(), sc_names!(self.app))
|
||||
|
|
|
@ -762,6 +762,24 @@ fn issue_1093_allow_ext_sc() {
|
|||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_subcommand_looks_like_built_in() {
|
||||
let res = App::new("cargo")
|
||||
.version("1.26.0")
|
||||
.setting(AppSettings::AllowExternalSubcommands)
|
||||
.subcommand(SubCommand::with_name("install"))
|
||||
.get_matches_from_safe(vec!["cargo", "install-update", "foo"]);
|
||||
assert!(res.is_ok());
|
||||
let m = res.unwrap();
|
||||
match m.subcommand() {
|
||||
(name, Some(args)) => {
|
||||
assert_eq!(name, "install-update");
|
||||
assert_eq!(args.values_of_lossy(""), Some(vec!["foo".to_string()]));
|
||||
}
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aaos_flags() {
|
||||
// flags
|
||||
|
|
Loading…
Reference in a new issue