mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
fix(help_template): Added cfg
This commit is contained in:
parent
a7a8241487
commit
c6058dee6e
3 changed files with 56 additions and 0 deletions
|
@ -137,6 +137,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
|
||||||
"name" => {
|
"name" => {
|
||||||
self.write_display_name();
|
self.write_display_name();
|
||||||
}
|
}
|
||||||
|
#[cfg(not(feature = "unstable-v5"))]
|
||||||
"bin" => {
|
"bin" => {
|
||||||
self.write_bin_name();
|
self.write_bin_name();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1042,6 +1042,27 @@ Options:
|
||||||
-V, --version Print version information
|
-V, --version Print version information
|
||||||
";
|
";
|
||||||
|
|
||||||
|
#[cfg(not(feature = "unstable-v5"))]
|
||||||
|
let cmd = Command::new("ripgrep")
|
||||||
|
.version("0.5")
|
||||||
|
.override_usage(
|
||||||
|
"\
|
||||||
|
rg [OPTIONS] <pattern> [<path> ...]
|
||||||
|
rg [OPTIONS] [-e PATTERN | -f FILE ]... [<path> ...]
|
||||||
|
rg [OPTIONS] --files [<path> ...]
|
||||||
|
rg [OPTIONS] --type-list",
|
||||||
|
)
|
||||||
|
.help_template(
|
||||||
|
"\
|
||||||
|
{bin} {version}
|
||||||
|
|
||||||
|
Usage: {usage}
|
||||||
|
|
||||||
|
Options:
|
||||||
|
{options}",
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-v5")]
|
||||||
let cmd = Command::new("ripgrep")
|
let cmd = Command::new("ripgrep")
|
||||||
.version("0.5")
|
.version("0.5")
|
||||||
.override_usage(
|
.override_usage(
|
||||||
|
|
|
@ -2,6 +2,16 @@ use super::utils;
|
||||||
|
|
||||||
use clap::{arg, Command};
|
use clap::{arg, Command};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "unstable-v5"))]
|
||||||
|
static EXAMPLE1_TMPL_S: &str = "{bin} {version}
|
||||||
|
{author}
|
||||||
|
{about}
|
||||||
|
|
||||||
|
Usage: {usage}
|
||||||
|
|
||||||
|
{all-args}";
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-v5")]
|
||||||
static EXAMPLE1_TMPL_S: &str = "{name} {version}
|
static EXAMPLE1_TMPL_S: &str = "{name} {version}
|
||||||
{author}
|
{author}
|
||||||
{about}
|
{about}
|
||||||
|
@ -10,6 +20,21 @@ Usage: {usage}
|
||||||
|
|
||||||
{all-args}";
|
{all-args}";
|
||||||
|
|
||||||
|
#[cfg(not(feature = "unstable-v5"))]
|
||||||
|
static EXAMPLE1_TMPS_F: &str = "{bin} {version}
|
||||||
|
{author}
|
||||||
|
{about}
|
||||||
|
|
||||||
|
Usage: {usage}
|
||||||
|
|
||||||
|
Options:
|
||||||
|
{options}
|
||||||
|
Arguments:
|
||||||
|
{positionals}
|
||||||
|
Commands:
|
||||||
|
{subcommands}";
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-v5")]
|
||||||
static EXAMPLE1_TMPS_F: &str = "{name} {version}
|
static EXAMPLE1_TMPS_F: &str = "{name} {version}
|
||||||
{author}
|
{author}
|
||||||
{about}
|
{about}
|
||||||
|
@ -105,11 +130,20 @@ fn template_unknowntag() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn template_author_version() {
|
fn template_author_version() {
|
||||||
|
#[cfg(not(feature = "unstable-v5"))]
|
||||||
|
let cmd = Command::new("MyApp")
|
||||||
|
.version("1.0")
|
||||||
|
.author("Kevin K. <kbknapp@gmail.com>")
|
||||||
|
.about("Does awesome things")
|
||||||
|
.help_template("{author}\n{version}\n{about}\n{bin}");
|
||||||
|
|
||||||
|
#[cfg(feature = "unstable-v5")]
|
||||||
let cmd = Command::new("MyApp")
|
let cmd = Command::new("MyApp")
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
.author("Kevin K. <kbknapp@gmail.com>")
|
.author("Kevin K. <kbknapp@gmail.com>")
|
||||||
.about("Does awesome things")
|
.about("Does awesome things")
|
||||||
.help_template("{author}\n{version}\n{about}\n{name}");
|
.help_template("{author}\n{version}\n{about}\n{name}");
|
||||||
|
|
||||||
utils::assert_output(
|
utils::assert_output(
|
||||||
cmd,
|
cmd,
|
||||||
"MyApp --help",
|
"MyApp --help",
|
||||||
|
|
Loading…
Reference in a new issue