From 514e6c13c2c4d1866a9570724684f9bac031956f Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Thu, 13 Jun 2024 14:30:05 -0700 Subject: [PATCH] Do not print true, false options for flags The user cannot write `--list false` for a flag. Fixes https://github.com/ConnorGray/clap-markdown/issues/19. --- docs/examples/complex-app.md | 3 --- src/lib.rs | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/examples/complex-app.md b/docs/examples/complex-app.md index af6e622..0c9aad8 100644 --- a/docs/examples/complex-app.md +++ b/docs/examples/complex-app.md @@ -47,9 +47,6 @@ does testing things * `-l`, `--list` — lists test values - Possible values: `true`, `false` - -
diff --git a/src/lib.rs b/src/lib.rs index dd3d152..489eaba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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());