diff --git a/docs/examples/complex-app.md b/docs/examples/complex-app.md
index 0c9aad8..a357309 100644
--- a/docs/examples/complex-app.md
+++ b/docs/examples/complex-app.md
@@ -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`
@@ -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:**
@@ -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`
+
+
+
diff --git a/docs/examples/complex_app.rs b/docs/examples/complex_app.rs
index ca7e437..021be97 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,
}
@@ -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)]
diff --git a/src/lib.rs b/src/lib.rs
index 2e966d1..5fec95b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -343,7 +343,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() {
@@ -377,9 +377,6 @@ fn build_command_markdown(
}
fn write_arg_markdown(buffer: &mut String, arg: &clap::Arg) -> fmt::Result {
- // Markdown list item
- write!(buffer, "* ")?;
-
let value_name: String = match arg.get_value_names() {
// TODO: What if multiple names are provided?
Some([name, ..]) => name.as_str().to_owned(),
@@ -389,6 +386,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() {