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 14, 2024
1 parent 4d0eaaf commit 5c61462
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/examples/complex-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This document contains the help content for the `complex-app` command-line progr

* [`complex-app`](#complex-app)
* [`complex-app test`](#complex-app-test)
* [`complex-app only-hidden-options`](#complex-app-only-hidden-options)

## `complex-app`

Expand All @@ -16,6 +17,7 @@ An example command-line tool
###### **Subcommands:**

* `test` — does testing things
* `only-hidden-options` — Demo that `Options` is not printed if all options are hidden

###### **Arguments:**

Expand Down Expand Up @@ -49,6 +51,14 @@ does testing things



## `complex-app only-hidden-options`

Demo that `Options` is not printed if all options are hidden

**Usage:** `complex-app only-hidden-options`



<hr/>

<small><i>
Expand Down
8 changes: 8 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 All @@ -32,6 +35,11 @@ enum Commands {
#[arg(short, long)]
list: bool,
},
/// Demo that `Options` is not printed if all options are hidden
OnlyHiddenOptions {
#[arg(short, long, hide = true)]
secret: bool,
},
}

#[derive(clap::ValueEnum)]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ fn build_command_markdown(

let non_pos: Vec<_> = command
.get_arguments()
.filter(|arg| !arg.is_positional())
.filter(|arg| !arg.is_positional() && !arg.is_hide_set())
.collect();

if !non_pos.is_empty() {
Expand Down

0 comments on commit 5c61462

Please sign in to comment.