Merge pull request #1227 from kbknapp/v3-dev

fix(Suggestions): disables suggestions when AllowExternalSubcommand i…
This commit is contained in:
Kevin K 2018-03-21 00:05:21 -04:00 committed by GitHub
commit 564f63640c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -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))

View file

@ -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