Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions clap_mangen/tests/snapshots/configured_display_order_args.roff
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.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\-O\fR|\fB\-\-first\fR] [\fB\-P\fR|\fB\-\-second\fR] [\fB\-Q\fR|\fB\-\-third\fR] [\fB\-\-fourth\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fI1st\fR] [\fI2nd\fR] [\fI3rd\fR]
.SH DESCRIPTION
.SH OPTIONS
.TP
\fB\-O\fR, \fB\-\-first\fR
Should be 1st
.TP
\fB\-P\fR, \fB\-\-second\fR
Should be 2nd
.TP
\fB\-Q\fR, \fB\-\-third\fR
Should be 3rd
.TP
\fB\-\-fourth\fR
Should be 4th
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help
.TP
[\fI1st\fR]
1st
.TP
[\fI2nd\fR]
2nd
.TP
[\fI3rd\fR]
3rd
37 changes: 37 additions & 0 deletions clap_mangen/tests/testsuite/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,43 @@ pub(crate) fn value_name_without_arg(name: &'static str) -> clap::Command {
)
}


pub(crate) fn configured_display_order_args(name: &'static str) -> clap::Command {
clap::Command::new(name)
.arg(clap::Arg::new("1st").help("1st"))
.arg(clap::Arg::new("2nd").help("2nd"))
.arg(clap::Arg::new("3rd").help("3rd").last(true))
.arg(
clap::Arg::new("c")
.long("third")
.short('Q')
.display_order(3)
.help("Should be 3rd"),
)
.arg(
clap::Arg::new("d")
.long("fourth")
.display_order(4)
.help("Should be 4th"),
)
.arg(
clap::Arg::new("a")
.long("first")
.short('O')
.display_order(1)
.help("Should be 1st"),
)
.arg(
clap::Arg::new("b")
.long("second")
.short('P')
.display_order(2)
.help("Should be 2nd"),
)

}


pub(crate) fn help_headings(name: &'static str) -> clap::Command {
clap::Command::new(name)
.arg(
Expand Down
11 changes: 11 additions & 0 deletions clap_mangen/tests/testsuite/roff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,14 @@ fn value_name_without_arg() {
cmd,
);
}

#[test]
fn configured_display_order_args() {
let name = "my-app";
let cmd = common::configured_display_order_args(name);

common::assert_matches(
snapbox::file!["../snapshots/configured_display_order_args.roff"],
cmd,
);
}