diff --git a/src/app/parser.rs b/src/app/parser.rs index e8729292..75c6fa5a 100644 --- a/src/app/parser.rs +++ b/src/app/parser.rs @@ -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)) diff --git a/tests/app_settings.rs b/tests/app_settings.rs index 0a4cb62f..24281d0f 100644 --- a/tests/app_settings.rs +++ b/tests/app_settings.rs @@ -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