Skip to content

Commit

Permalink
Do not print true, false options for flags
Browse files Browse the repository at this point in the history
The user cannot write `--list false` for a flag.

Fixes ConnorGray#19.
  • Loading branch information
ilyagr committed Jun 13, 2024
1 parent afbc849 commit 514e6c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 0 additions & 3 deletions docs/examples/complex-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ does testing things

* `-l`, `--list` — lists test values

Possible values: `true`, `false`




<hr/>
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,9 @@ fn write_arg_markdown(buffer: &mut String, arg: &clap::Arg) -> fmt::Result {
.filter(|pv| !pv.is_hide_set())
.collect();

if !possible_values.is_empty() {
if !matches!(arg.get_action(), clap::ArgAction::SetTrue)
&& !possible_values.is_empty()
{
let any_have_help: bool =
possible_values.iter().any(|pv| pv.get_help().is_some());

Expand Down

0 comments on commit 514e6c1

Please sign in to comment.