Skip to content

Commit

Permalink
Auto merge of #299 - kbknapp:issue-298, r=Vinatorul
Browse files Browse the repository at this point in the history
fix(Usage Strings): fixes a bug ordering of elements in usage strings

Closes #298
  • Loading branch information
homu committed Oct 1, 2015
2 parents cde710f + 914b332 commit 7b50f76
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,6 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
acc + &format!(" {}", s)[..]
});


if !self.flags.is_empty() && !self.settings.is_set(&AppSettings::UnifiedHelpMessage) {
usage.push_str(" [FLAGS]");
} else {
Expand All @@ -1335,11 +1334,16 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
self.opts.values().any(|a| !a.settings.is_set(&ArgSettings::Required)) {
usage.push_str(" [OPTIONS]");
}

usage.push_str(&req_string[..]);

// places a '--' in the usage string if there are args and options
// supporting multiple values
if !self.positionals_idx.is_empty() && self.opts.values().any(|a| a.settings.is_set(&ArgSettings::Multiple)) &&
!self.opts.values().any(|a| a.settings.is_set(&ArgSettings::Required)) &&
self.subcommands.is_empty() {
if !self.positionals_idx.is_empty() &&
(self.opts.values().any(|a| a.settings.is_set(&ArgSettings::Multiple)) ||
self.positionals_idx.values().any(|a| a.settings.is_set(&ArgSettings::Multiple))) &&
!self.opts.values().any(|a| a.settings.is_set(&ArgSettings::Required)) &&
self.subcommands.is_empty() {
usage.push_str(" [--]")
}
if !self.positionals_idx.is_empty() &&
Expand All @@ -1348,7 +1352,6 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
usage.push_str(" [ARGS]");
}

usage.push_str(&req_string[..]);

if !self.subcommands.is_empty() && !self.settings.is_set(&AppSettings::SubcommandRequired) {
usage.push_str(" [SUBCOMMAND]");
Expand Down

0 comments on commit 7b50f76

Please sign in to comment.