diff --git a/clap_mangen/tests/snapshots/flatten_help.roff b/clap_mangen/tests/snapshots/flatten_help.roff new file mode 100644 index 000000000000..e9ab64a9d6fc --- /dev/null +++ b/clap_mangen/tests/snapshots/flatten_help.roff @@ -0,0 +1,26 @@ +.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\-c \fR] [\fB\-v \fR] [\fB\-h\fR|\fB\-\-help\fR] [\fIsubcommands\fR] +.SH DESCRIPTION +.SH OPTIONS +.TP +\fB\-c\fR + +.TP +\fB\-v\fR + +.TP +\fB\-h\fR, \fB\-\-help\fR +Print help +.SH SUBCOMMANDS +.TP +my\-app\-test(1) +Subcommand +with a second line +.TP +my\-app\-help(1) +Print this message or the help of the given subcommand(s) diff --git a/clap_mangen/tests/testsuite/roff.rs b/clap_mangen/tests/testsuite/roff.rs index 9f3f4ee660ee..a24e2ba6d491 100644 --- a/clap_mangen/tests/testsuite/roff.rs +++ b/clap_mangen/tests/testsuite/roff.rs @@ -105,3 +105,17 @@ fn value_name_without_arg() { cmd, ); } + +#[test] +fn flatten_help_false() { + let name = "my-app"; + let cmd = common::basic_command(name).flatten_help(false); + common::assert_matches(snapbox::file!["../snapshots/basic.bash.roff"], cmd); +} + +#[test] +fn flatten_help_true() { + let name = "my-app"; + let cmd = common::basic_command(name).flatten_help(true); + common::assert_matches(snapbox::file!["../snapshots/flatten_help.roff"], cmd); +}