-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: fixes a critical bug where subcommand settings were being propogated too far Closes #832 * imp: adds ArgGroup::multiple to the supported YAML fields for building ArgGroups from YAML Closes #840 * chore: increase version
- Loading branch information
Showing
6 changed files
with
31 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
|
||
name = "clap" | ||
version = "2.20.1" | ||
version = "2.20.2" | ||
authors = ["Kevin K. <[email protected]>"] | ||
exclude = ["examples/*", "clap-test/*", "tests/*", "benches/*", "*.png", "clap-perf/*", "*.dot"] | ||
repository = "https://github.com/kbknapp/clap-rs.git" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,35 +236,28 @@ impl<'a, 'b> Parser<'a, 'b> | |
} | ||
|
||
pub fn add_subcommand(&mut self, mut subcmd: App<'a, 'b>) { | ||
debugln!("Parser::add_subcommand;"); | ||
debugln!("Parser::add_subcommand: Term width...{:?}", | ||
self.meta.term_w); | ||
debugln!("Parser::add_subcommand: term_w={:?}, name={}", | ||
self.meta.term_w, subcmd.p.meta.name); | ||
subcmd.p.meta.term_w = self.meta.term_w; | ||
debug!("Parser::add_subcommand: Is help..."); | ||
if subcmd.p.meta.name == "help" { | ||
sdebugln!("Yes"); | ||
self.settings.unset(AppSettings::NeedsSubcommandHelp); | ||
} else { | ||
sdebugln!("No"); | ||
} | ||
|
||
self.subcommands.push(subcmd); | ||
} | ||
|
||
pub fn propogate_settings(&mut self) { | ||
debugln!("Parser::propogate_settings;"); | ||
debugln!("Parser::propogate_settings: self={}, g_settings={:#?}", | ||
self.meta.name, self.g_settings); | ||
for sc in &mut self.subcommands { | ||
debugln!("Parser::propogate_settings: sc={}, settings={:#?}, g_settings={:#?}", | ||
sc.p.meta.name, sc.p.settings, sc.p.g_settings); | ||
// We have to create a new scope in order to tell rustc the borrow of `sc` is | ||
// done and to recursively call this method | ||
{ | ||
let vsc = self.settings.is_set(AppSettings::VersionlessSubcommands); | ||
let gv = self.settings.is_set(AppSettings::GlobalVersion); | ||
|
||
debugln!("Parser::propogate_settings:iter: VersionlessSubcommands set...{:?}", | ||
vsc); | ||
debugln!("Parser::propogate_settings:iter: GlobalVersion set...{:?}", | ||
gv); | ||
|
||
if vsc { | ||
sc.p.settings.set(AppSettings::DisableVersion); | ||
} | ||
|
@@ -273,7 +266,7 @@ impl<'a, 'b> Parser<'a, 'b> | |
sc.p.meta.version = Some(self.meta.version.unwrap()); | ||
} | ||
sc.p.settings = sc.p.settings | self.g_settings; | ||
sc.p.g_settings = sc.p.settings | self.g_settings; | ||
sc.p.g_settings = sc.p.g_settings | self.g_settings; | ||
} | ||
sc.p.propogate_settings(); | ||
} | ||
|
@@ -982,6 +975,7 @@ impl<'a, 'b> Parser<'a, 'b> | |
&self.create_current_usage(matcher), | ||
self.color())); | ||
} else if self.is_set(AppSettings::SubcommandRequiredElseHelp) { | ||
debugln!("parser::get_matches_with: SubcommandRequiredElseHelp=true"); | ||
let mut out = vec![]; | ||
try!(self.write_help_err(&mut out)); | ||
return Err(Error { | ||
|
@@ -1124,6 +1118,8 @@ impl<'a, 'b> Parser<'a, 'b> | |
"" | ||
}, | ||
&*sc.p.meta.name)); | ||
println!("Parser::parse_subcommand: About to parse sc={}", sc.p.meta.name); | ||
println!("Parser::parse_subcommand: sc settings={:#?}", sc.p.settings); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
uberjay
|
||
try!(sc.p.get_matches_with(&mut sc_matcher, it)); | ||
matcher.subcommand(SubCommand { | ||
name: sc.p.meta.name.clone(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, I think these ought to be
debugln!
, or removed altogether?