test(clap_mangen): Hidden flags in synopsis

This commit is contained in:
ducaale 2022-04-03 00:28:19 +01:00
parent b3b49855ab
commit ddc83bfdc8
3 changed files with 33 additions and 0 deletions

View file

@ -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<std::path::Path>, cmd: clap::Command) {
let mut buf = vec![];
clap_mangen::Man::new(cmd).render(&mut buf).unwrap();

View file

@ -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);
}

View file

@ -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