Skip to content

Commit

Permalink
fix(Custom Usage Strings): fixes the usage string regression when usi…
Browse files Browse the repository at this point in the history
…ng help templates
  • Loading branch information
kbknapp committed Mar 30, 2017
1 parent f922b05 commit 0e4fd96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ impl<'a> Help<'a> {
parser.meta.about.unwrap_or("unknown about")));
}
b"usage" => {
try!(write!(self.writer, "{}", usage::create_help_usage(parser, true)));
try!(write!(self.writer, "{}", usage::create_usage_no_title(parser, &[])));
}
b"all-args" => {
try!(self.write_all_args(&parser));
Expand Down
22 changes: 21 additions & 1 deletion tests/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,27 @@ fn ripgrep_usage() {
rg [OPTIONS] --files [<path> ...]
rg [OPTIONS] --type-list");

assert!(test::compare_output(app, "ripgrep --help", RIPGREP_USAGE, false));
assert!(test::compare_output(app, "rg --help", RIPGREP_USAGE, false));
}

#[test]
fn ripgrep_usage_using_templates() {
let app = App::new("ripgrep")
.version("0.5")
.usage("
rg [OPTIONS] <pattern> [<path> ...]
rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
rg [OPTIONS] --files [<path> ...]
rg [OPTIONS] --type-list")
.template("\
{bin} {version}
USAGE:{usage}
FLAGS:
{flags}");

assert!(test::compare_output(app, "rg --help", RIPGREP_USAGE, false));
}

#[test]
Expand Down

0 comments on commit 0e4fd96

Please sign in to comment.