From 8ef59d98c7085a41b3083e8c6baf1796e5c8998e Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Thu, 13 Jun 2024 14:41:35 -0700 Subject: [PATCH] Do not show hidden arguments Fixes https://github.com/ConnorGray/clap-markdown/issues/18 --- docs/examples/complex_app.rs | 3 +++ src/lib.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/docs/examples/complex_app.rs b/docs/examples/complex_app.rs index ca7e437..3f144f0 100644 --- a/docs/examples/complex_app.rs +++ b/docs/examples/complex_app.rs @@ -20,6 +20,9 @@ pub struct Cli { #[arg(short, long, action = clap::ArgAction::Count)] debug: u8, + #[arg(short, long, hide = true)] + secret_arg: bool, + #[command(subcommand)] command: Option, } diff --git a/src/lib.rs b/src/lib.rs index 2e966d1..7e149ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -377,6 +377,10 @@ fn build_command_markdown( } fn write_arg_markdown(buffer: &mut String, arg: &clap::Arg) -> fmt::Result { + // Don't print docs for hidden args + if arg.is_hide_set() { + return Ok(()); + } // Markdown list item write!(buffer, "* ")?;