mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
fix(help): Correctly show help for fake flags
This commit is contained in:
parent
d63106b9f6
commit
3eaf1af052
4 changed files with 18 additions and 17 deletions
|
@ -4078,7 +4078,9 @@ impl Arg {
|
|||
}
|
||||
|
||||
pub(crate) fn is_takes_value_set(&self) -> bool {
|
||||
self.get_action().takes_values()
|
||||
self.get_num_args()
|
||||
.unwrap_or_else(|| 1.into())
|
||||
.takes_values()
|
||||
}
|
||||
|
||||
/// Report whether [`Arg::allow_hyphen_values`] is set
|
||||
|
|
|
@ -704,13 +704,14 @@ fn assert_arg(arg: &Arg) {
|
|||
arg.get_id(),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
arg.get_action().takes_values(),
|
||||
arg.is_takes_value_set(),
|
||||
"Argument `{}`'s selected action {:?} contradicts `takes_value`",
|
||||
arg.get_id(),
|
||||
arg.get_action()
|
||||
);
|
||||
if arg.is_takes_value_set() {
|
||||
assert!(
|
||||
arg.get_action().takes_values(),
|
||||
"Argument `{}`'s selected action {:?} contradicts `takes_value`",
|
||||
arg.get_id(),
|
||||
arg.get_action()
|
||||
);
|
||||
}
|
||||
if let Some(action_type_id) = arg.get_action().value_type_id() {
|
||||
assert_eq!(
|
||||
action_type_id,
|
||||
|
|
|
@ -99,7 +99,7 @@ pub(crate) fn options(roff: &mut Roff, cmd: &clap::Command) {
|
|||
(None, None) => vec![],
|
||||
};
|
||||
|
||||
if opt.get_action().takes_values() {
|
||||
if opt.get_num_args().expect("built").takes_values() {
|
||||
if let Some(value) = &opt.get_value_names() {
|
||||
header.push(roman("="));
|
||||
header.push(italic(value.join(" ")));
|
||||
|
@ -288,7 +288,7 @@ fn option_environment(opt: &clap::Arg) -> Option<Vec<Inline>> {
|
|||
}
|
||||
|
||||
fn option_default_values(opt: &clap::Arg) -> Option<String> {
|
||||
if opt.is_hide_default_value_set() || !opt.get_action().takes_values() {
|
||||
if opt.is_hide_default_value_set() || !opt.get_num_args().expect("built").takes_values() {
|
||||
return None;
|
||||
} else if !opt.get_default_values().is_empty() {
|
||||
let values = opt
|
||||
|
|
|
@ -11,15 +11,13 @@ Options:
|
|||
-V, --version Print version
|
||||
|
||||
TESTS:
|
||||
--empty [<empty>] File is empty and is either a regular file or a directory [default: false]
|
||||
[possible values: true, false]
|
||||
--name <name> Base of file name (the path with the leading directories removed) matches
|
||||
shell pattern pattern
|
||||
--empty File is empty and is either a regular file or a directory
|
||||
--name <name> Base of file name (the path with the leading directories removed) matches shell
|
||||
pattern pattern
|
||||
|
||||
OPERATORS:
|
||||
-o, --or [<or>] expr2 is not evaluate if exp1 is true [default: false] [possible values: true,
|
||||
false]
|
||||
-a, --and [<and>] Same as `expr1 expr1` [default: false] [possible values: true, false]
|
||||
-o, --or expr2 is not evaluate if exp1 is true
|
||||
-a, --and Same as `expr1 expr1`
|
||||
|
||||
$ find --empty -o --name .keep
|
||||
[
|
||||
|
|
Loading…
Reference in a new issue