mirror of
https://github.com/clap-rs/clap
synced 2025-01-05 17:28:42 +00:00
fix(help): Skip [OPTIONS]
if help/version action
Our code for detecting when to skip this in the usage was never updated for actions.
This commit is contained in:
parent
22b545b98b
commit
36afe99bfa
2 changed files with 18 additions and 3 deletions
|
@ -4,6 +4,7 @@
|
||||||
#![cfg_attr(not(feature = "usage"), allow(dead_code))]
|
#![cfg_attr(not(feature = "usage"), allow(dead_code))]
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
|
use crate::builder::ArgAction;
|
||||||
use crate::builder::StyledStr;
|
use crate::builder::StyledStr;
|
||||||
use crate::builder::Styles;
|
use crate::builder::Styles;
|
||||||
use crate::builder::{ArgPredicate, Command};
|
use crate::builder::{ArgPredicate, Command};
|
||||||
|
@ -210,6 +211,20 @@ impl<'cmd> Usage<'cmd> {
|
||||||
debug!("Usage::needs_options_tag:iter Option is built-in");
|
debug!("Usage::needs_options_tag:iter Option is built-in");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
match f.get_action() {
|
||||||
|
ArgAction::Set
|
||||||
|
| ArgAction::Append
|
||||||
|
| ArgAction::SetTrue
|
||||||
|
| ArgAction::SetFalse
|
||||||
|
| ArgAction::Count => {}
|
||||||
|
ArgAction::Help
|
||||||
|
| ArgAction::HelpShort
|
||||||
|
| ArgAction::HelpLong
|
||||||
|
| ArgAction::Version => {
|
||||||
|
debug!("Usage::needs_options_tag:iter Option is built-in");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if f.is_hide_set() {
|
if f.is_hide_set() {
|
||||||
debug!("Usage::needs_options_tag:iter Option is hidden");
|
debug!("Usage::needs_options_tag:iter Option is hidden");
|
||||||
|
|
|
@ -1068,7 +1068,7 @@ fn explicit_short_long_help() {
|
||||||
static SHORT_ABOUT: &str = "\
|
static SHORT_ABOUT: &str = "\
|
||||||
bar
|
bar
|
||||||
|
|
||||||
Usage: myapp [OPTIONS] [arg1]
|
Usage: myapp [arg1]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
[arg1] some option
|
[arg1] some option
|
||||||
|
@ -1084,7 +1084,7 @@ something really really long, with
|
||||||
multiple lines of text
|
multiple lines of text
|
||||||
that should be displayed
|
that should be displayed
|
||||||
|
|
||||||
Usage: myapp [OPTIONS] [arg1]
|
Usage: myapp [arg1]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
[arg1]
|
[arg1]
|
||||||
|
@ -1351,7 +1351,7 @@ fn override_help_short() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static OVERRIDE_HELP_LONG: &str = "\
|
static OVERRIDE_HELP_LONG: &str = "\
|
||||||
Usage: test [OPTIONS]
|
Usage: test
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --hell Print help
|
-h, --hell Print help
|
||||||
|
|
Loading…
Reference in a new issue