Skip to content

Commit

Permalink
Do not show hidden arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Jun 13, 2024
1 parent d3985a3 commit 1648d59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/examples/complex_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Commands>,
}
Expand Down
8 changes: 6 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,10 @@ fn build_command_markdown(
}

fn write_arg_markdown(buffer: &mut String, arg: &clap::Arg) -> fmt::Result {
// Markdown list item
write!(buffer, "* ")?;
// Don't print docs for hidden args
if arg.is_hide_set() {
return Ok(());
}

let value_name: String = match arg.get_value_names() {
// TODO: What if multiple names are provided?
Expand All @@ -389,6 +391,8 @@ fn write_arg_markdown(buffer: &mut String, arg: &clap::Arg) -> fmt::Result {
None => arg.get_id().to_string().to_ascii_uppercase(),
};

// Markdown list item
write!(buffer, "* ")?;
match (arg.get_short(), arg.get_long()) {
(Some(short), Some(long)) => {
if arg.get_action().takes_values() {
Expand Down

0 comments on commit 1648d59

Please sign in to comment.