mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
test(clap_mangen): Hidden flags in synopsis
This commit is contained in:
parent
b3b49855ab
commit
ddc83bfdc8
3 changed files with 33 additions and 0 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
15
clap_mangen/tests/snapshots/hidden_option.bash.roff
Normal file
15
clap_mangen/tests/snapshots/hidden_option.bash.roff
Normal 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
|
||||
|
Loading…
Reference in a new issue