Skip to content

Commit

Permalink
fix: fixes a bug where args with last(true) and required(true) set we…
Browse files Browse the repository at this point in the history
…re not being printed in the usage string

Closes #944
  • Loading branch information
kbknapp committed May 7, 2017
1 parent 2e0df55 commit 3ac533f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn create_help_usage(p: &Parser, incl_reqs: bool) -> String {
usage.push_str(" [--]");
}
let not_req_or_hidden =
|p: &PosBuilder| !p.is_set(ArgSettings::Required) && !p.is_set(ArgSettings::Hidden);
|p: &PosBuilder| (!p.is_set(ArgSettings::Required) || p.is_set(ArgSettings::Last)) && !p.is_set(ArgSettings::Hidden);
if p.has_positionals() && p.positionals.values().any(not_req_or_hidden) {
if let Some(args_tag) = get_args_tag(p, incl_reqs) {
usage.push_str(&*args_tag);
Expand All @@ -114,8 +114,10 @@ pub fn create_help_usage(p: &Parser, incl_reqs: bool) -> String {
.expect(INTERNAL_ERROR_MSG);
debugln!("usage::create_help_usage: '{}' has .last(true)", pos.name());
let req = pos.is_set(ArgSettings::Required);
if req {
if req && p.positionals.values().any(|p| !p.is_set(ArgSettings::Required)) {
usage.push_str(" -- <");
} else if req {
usage.push_str(" [--] <");
} else {
usage.push_str(" [-- <");
}
Expand Down

0 comments on commit 3ac533f

Please sign in to comment.