Skip to content

Commit 0e4fd96

Browse files
committed
fix(Custom Usage Strings): fixes the usage string regression when using help templates
1 parent f922b05 commit 0e4fd96

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/app/help.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ impl<'a> Help<'a> {
888888
parser.meta.about.unwrap_or("unknown about")));
889889
}
890890
b"usage" => {
891-
try!(write!(self.writer, "{}", usage::create_help_usage(parser, true)));
891+
try!(write!(self.writer, "{}", usage::create_usage_no_title(parser, &[])));
892892
}
893893
b"all-args" => {
894894
try!(self.write_all_args(&parser));

tests/help.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,27 @@ fn ripgrep_usage() {
686686
rg [OPTIONS] --files [<path> ...]
687687
rg [OPTIONS] --type-list");
688688

689-
assert!(test::compare_output(app, "ripgrep --help", RIPGREP_USAGE, false));
689+
assert!(test::compare_output(app, "rg --help", RIPGREP_USAGE, false));
690+
}
691+
692+
#[test]
693+
fn ripgrep_usage_using_templates() {
694+
let app = App::new("ripgrep")
695+
.version("0.5")
696+
.usage("
697+
rg [OPTIONS] <pattern> [<path> ...]
698+
rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
699+
rg [OPTIONS] --files [<path> ...]
700+
rg [OPTIONS] --type-list")
701+
.template("\
702+
{bin} {version}
703+
704+
USAGE:{usage}
705+
706+
FLAGS:
707+
{flags}");
708+
709+
assert!(test::compare_output(app, "rg --help", RIPGREP_USAGE, false));
690710
}
691711

692712
#[test]

0 commit comments

Comments
 (0)