diff --git a/clap_mangen/src/render.rs b/clap_mangen/src/render.rs index 93fa7875..720b83b5 100644 --- a/clap_mangen/src/render.rs +++ b/clap_mangen/src/render.rs @@ -31,7 +31,7 @@ pub(crate) fn description(roff: &mut Roff, cmd: &clap::Command) { pub(crate) fn synopsis(roff: &mut Roff, cmd: &clap::Command) { let mut line = vec![bold(cmd.get_name()), roman(" ")]; - for opt in cmd.get_arguments() { + for opt in cmd.get_arguments().filter(|i| !i.is_hide_set()) { let (lhs, rhs) = option_markers(opt); match (opt.get_short(), opt.get_long()) { (Some(short), Some(long)) => { diff --git a/clap_mangen/tests/common.rs b/clap_mangen/tests/common.rs index 52f0e7f3..2ab5d932 100644 --- a/clap_mangen/tests/common.rs +++ b/clap_mangen/tests/common.rs @@ -220,6 +220,17 @@ pub fn value_hint_command(name: &'static str) -> clap::Command<'static> { ) } +pub fn hidden_option_command(name: &'static str) -> clap::Command<'static> { + clap::Command::new(name) + .arg(clap::Arg::new("config").long("--config").takes_value(true)) + .arg( + clap::Arg::new("no-config") + .long("--no-config") + .hide(true) + .overrides_with("config"), + ) +} + pub fn assert_matches_path(expected_path: impl AsRef, cmd: clap::Command) { let mut buf = vec![]; clap_mangen::Man::new(cmd).render(&mut buf).unwrap(); diff --git a/clap_mangen/tests/roff.rs b/clap_mangen/tests/roff.rs index 3770dd1c..d48d070f 100644 --- a/clap_mangen/tests/roff.rs +++ b/clap_mangen/tests/roff.rs @@ -48,3 +48,10 @@ fn value_hint() { let cmd = common::value_hint_command(name); common::assert_matches_path("tests/snapshots/value_hint.bash.roff", cmd); } + +#[test] +fn hidden_options() { + let name = "my-app"; + let cmd = common::hidden_option_command(name); + common::assert_matches_path("tests/snapshots/hidden_option.bash.roff", cmd); +} diff --git a/clap_mangen/tests/snapshots/hidden_option.bash.roff b/clap_mangen/tests/snapshots/hidden_option.bash.roff new file mode 100644 index 00000000..1e9d119c --- /dev/null +++ b/clap_mangen/tests/snapshots/hidden_option.bash.roff @@ -0,0 +1,15 @@ +.ie /n(.g .ds Aq /(aq +.el .ds Aq ' +.TH my-app 1 "my-app " +.SH NAME +my/-app +.SH SYNOPSIS +/fBmy/-app/fR [/fB/-h/fR|/fB/-/-help/fR] [/fB/-/-config/fR] +.SH DESCRIPTION +.SH OPTIONS +.TP +/fB/-h/fR, /fB/-/-help/fR +Print help information +.TP +/fB/-/-config/fR +