Skip to content

Commit

Permalink
test(mangen): Show help_heading is ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAdk committed Dec 24, 2024
1 parent cff27db commit 540a538
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
23 changes: 23 additions & 0 deletions clap_mangen/tests/snapshots/help_headings.bash.roff
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.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\-r\fR|\fB\-\-recursive\fR] [\fB\-f\fR|\fB\-\-force\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fIcolor\fR]
.SH DESCRIPTION
.SH OPTIONS
.TP
\fB\-r\fR, \fB\-\-recursive\fR

.TP
\fB\-f\fR, \fB\-\-force\fR

.TP
\fB\-h\fR, \fB\-\-help\fR
Print help
.TP
[\fIcolor\fR]

.br
[\fIpossible values: \fRalways, never, auto]
31 changes: 31 additions & 0 deletions clap_mangen/tests/testsuite/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,34 @@ pub(crate) fn value_name_without_arg(name: &'static str) -> clap::Command {
.action(clap::ArgAction::SetTrue),
)
}

pub(crate) fn help_headings(name: &'static str) -> clap::Command {
clap::Command::new(name)
.arg(
clap::Arg::new("recursive")
.long("recursive")
.short('r')
.action(clap::ArgAction::SetTrue),
)
.next_help_heading("Conflict Options")
.arg(
clap::Arg::new("force")
.long("force")
.short('f')
.action(clap::ArgAction::SetTrue),
)
.next_help_heading("Hidden Options")
.arg(
clap::Arg::new("debug")
.long("debug")
.short('d')
.hide(true)
.action(clap::ArgAction::SetTrue),
)
.next_help_heading("Global Options")
.arg(
clap::Arg::new("color")
.global(true)
.value_parser(["always", "never", "auto"]),
)
}
7 changes: 7 additions & 0 deletions clap_mangen/tests/testsuite/roff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ fn sub_subcommands_help() {
}
}

#[test]
fn help_headings() {
let name = "my-app";
let cmd = common::help_headings(name);
common::assert_matches(snapbox::file!["../snapshots/help_headings.bash.roff"], cmd);
}

#[test]
fn value_name_without_arg() {
let name = "my-app";
Expand Down

0 comments on commit 540a538

Please sign in to comment.