mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
feat(help): Expose clap's indentation to help_template
This will make it easier for help templates to be consistent with clap
This commit is contained in:
parent
803d87b193
commit
439c9e7a91
5 changed files with 15 additions and 8 deletions
|
@ -74,6 +74,7 @@ Deprecated
|
||||||
- Added `TypedValueParser::map` to make it easier to reuse existing value parsers
|
- Added `TypedValueParser::map` to make it easier to reuse existing value parsers
|
||||||
- *(error)* `Error::apply` for changing the formatter for dropping binary size
|
- *(error)* `Error::apply` for changing the formatter for dropping binary size
|
||||||
- *(help)* Show `PossibleValue::help` in long help (`--help`) (#3312)
|
- *(help)* Show `PossibleValue::help` in long help (`--help`) (#3312)
|
||||||
|
- *(help)* New `{tab}` variable for `Command::help_template`
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
|
|
|
@ -1706,6 +1706,7 @@ impl Command {
|
||||||
/// * `{options}` - Help for options.
|
/// * `{options}` - Help for options.
|
||||||
/// * `{positionals}` - Help for positional arguments.
|
/// * `{positionals}` - Help for positional arguments.
|
||||||
/// * `{subcommands}` - Help for subcommands.
|
/// * `{subcommands}` - Help for subcommands.
|
||||||
|
/// * `{tag}` - Standard tab sized used within clap
|
||||||
/// * `{after-help}` - Help from [`Command::after_help`] or [`Command::after_long_help`].
|
/// * `{after-help}` - Help from [`Command::after_help`] or [`Command::after_long_help`].
|
||||||
/// * `{before-help}` - Help from [`Command::before_help`] or [`Command::before_long_help`].
|
/// * `{before-help}` - Help from [`Command::before_help`] or [`Command::before_long_help`].
|
||||||
///
|
///
|
||||||
|
|
|
@ -31,15 +31,17 @@ pub(crate) struct Help<'cmd, 'writer> {
|
||||||
// Public Functions
|
// Public Functions
|
||||||
impl<'cmd, 'writer> Help<'cmd, 'writer> {
|
impl<'cmd, 'writer> Help<'cmd, 'writer> {
|
||||||
const DEFAULT_TEMPLATE: &'static str = "\
|
const DEFAULT_TEMPLATE: &'static str = "\
|
||||||
{before-help}{about-with-newline}\n\
|
{before-help}{about-with-newline}
|
||||||
{usage-heading}\n {usage}\n\
|
{usage-heading}
|
||||||
\n\
|
{tab}{usage}
|
||||||
{all-args}{after-help}\
|
|
||||||
|
{all-args}{after-help}\
|
||||||
";
|
";
|
||||||
|
|
||||||
const DEFAULT_NO_ARGS_TEMPLATE: &'static str = "\
|
const DEFAULT_NO_ARGS_TEMPLATE: &'static str = "\
|
||||||
{before-help}{about-with-newline}\n\
|
{before-help}{about-with-newline}
|
||||||
{usage-heading}\n {usage}{after-help}\
|
{usage-heading}
|
||||||
|
{tab}{usage}{after-help}\
|
||||||
";
|
";
|
||||||
|
|
||||||
/// Create a new `Help` instance.
|
/// Create a new `Help` instance.
|
||||||
|
@ -186,6 +188,9 @@ impl<'cmd, 'writer> Help<'cmd, 'writer> {
|
||||||
"subcommands" => {
|
"subcommands" => {
|
||||||
self.write_subcommands(self.cmd);
|
self.write_subcommands(self.cmd);
|
||||||
}
|
}
|
||||||
|
"tab" => {
|
||||||
|
self.none(TAB);
|
||||||
|
}
|
||||||
"after-help" => {
|
"after-help" => {
|
||||||
self.write_after_help();
|
self.write_after_help();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub const FULL_TEMPLATE: &str = "\
|
||||||
{before-help}{name} {version}
|
{before-help}{name} {version}
|
||||||
{author-with-newline}{about-with-newline}
|
{author-with-newline}{about-with-newline}
|
||||||
{usage-heading}
|
{usage-heading}
|
||||||
{usage}
|
{tab}{usage}
|
||||||
|
|
||||||
{all-args}{after-help}";
|
{all-args}{after-help}";
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub const FULL_TEMPLATE: &str = "\
|
||||||
{before-help}{name} {version}
|
{before-help}{name} {version}
|
||||||
{author-with-newline}{about-with-newline}
|
{author-with-newline}{about-with-newline}
|
||||||
{usage-heading}
|
{usage-heading}
|
||||||
{usage}
|
{tab}{usage}
|
||||||
|
|
||||||
{all-args}{after-help}";
|
{all-args}{after-help}";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue