From 33924e884461983c4e6b5ea1330fecc769a4ade7 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Tue, 1 Nov 2016 23:31:29 -0400 Subject: [PATCH] fix(Low Index Multiples): fixes a bug where using low index multiples was propgated to subcommands Closes #725 --- src/app/mod.rs | 2 -- src/app/parser.rs | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index cb4f7818750..481e920a729 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1322,8 +1322,6 @@ impl<'a, 'b> App<'a, 'b> { where I: IntoIterator, T: Into + Clone { - // Verify all positional assertions pass - self.p.verify_positionals(); // If there are global arguments, or settings we need to propgate them down to subcommands // before parsing incase we run into a subcommand self.p.propogate_globals(); diff --git a/src/app/parser.rs b/src/app/parser.rs index b11c52689c3..e5523bd1762 100644 --- a/src/app/parser.rs +++ b/src/app/parser.rs @@ -542,7 +542,7 @@ impl<'a, 'b> Parser<'a, 'b> "When using a positional argument with .multiple(true) that is *not the last* \ positional argument, the last positional argument (i.e the one with the highest \ index) *must* have .required(true) set."); - + debug_assert!({ let num = self.positionals.len() - 1; self.positionals.get(num).unwrap().is_set(ArgSettings::Multiple) @@ -704,10 +704,13 @@ impl<'a, 'b> Parser<'a, 'b> it: &mut Peekable) -> ClapResult<()> where I: Iterator, - T: Into + Clone + T: Into + Clone { debugln!("fn=get_matches_with;"); - // First we create the `--help` and `--version` arguments and add them if + // Verify all positional assertions pass + self.verify_positionals(); + + // Next we create the `--help` and `--version` arguments and add them if // necessary self.create_help_and_version(); @@ -719,7 +722,7 @@ impl<'a, 'b> Parser<'a, 'b> debugln!("Begin parsing '{:?}' ({:?})", arg_os, &*arg_os.as_bytes()); // Is this a new argument, or values from a previous option? - let starts_new_arg = is_new_arg(&arg_os); + let starts_new_arg = is_new_arg(&arg_os); // Has the user already passed '--'? Meaning only positional args follow if !self.trailing_vals {