Skip to content

Commit

Permalink
imp(parser.rs): Provide a way to create a usage string without the US…
Browse files Browse the repository at this point in the history
…AGE: title
  • Loading branch information
hgrecco committed Apr 13, 2016
1 parent 9d757e8 commit a91d378
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,16 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
debugln!("fn=create_usage;");
let mut usage = String::with_capacity(75);
usage.push_str("USAGE:\n ");
usage.push_str(&self.create_usage_no_title(&used));
usage
}

// Creates a usage string (*without title*) if one was not provided by the user
// manually. This happens just
// after all arguments were parsed, but before any subcommands have been parsed
// (so as to give subcommands their own usage recursively)
pub fn create_usage_no_title(&self, used: &[&str]) -> String {
let mut usage = String::with_capacity(75);
if let Some(u) = self.meta.usage_str {
usage.push_str(&*u);
} else if used.is_empty() {
Expand Down

0 comments on commit a91d378

Please sign in to comment.