Skip to content

Commit 1d261e4

Browse files
Eric GumbaEric Gumba
authored andcommitted
test(clap_mangen): Test mangen display order
1 parent 4c03930 commit 1d261e4

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.ie \n(.g .ds Aq \(aq
2+
.el .ds Aq '
3+
.TH my-app 1 "my-app "
4+
.SH NAME
5+
my\-app
6+
.SH SYNOPSIS
7+
\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]
8+
.SH DESCRIPTION
9+
.SH OPTIONS
10+
.TP
11+
\fB\-O\fR, \fB\-\-first\fR
12+
Should be 1st
13+
.TP
14+
\fB\-P\fR, \fB\-\-second\fR
15+
Should be 2nd
16+
.TP
17+
\fB\-Q\fR, \fB\-\-third\fR
18+
Should be 3rd
19+
.TP
20+
\fB\-\-fourth\fR
21+
Should be 4th
22+
.TP
23+
\fB\-h\fR, \fB\-\-help\fR
24+
Print help
25+
.TP
26+
[\fI1st\fR]
27+
1st
28+
.TP
29+
[\fI2nd\fR]
30+
2nd
31+
.TP
32+
[\fI3rd\fR]
33+
3rd

clap_mangen/tests/testsuite/common.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,43 @@ pub(crate) fn value_name_without_arg(name: &'static str) -> clap::Command {
324324
)
325325
}
326326

327+
328+
pub(crate) fn configured_display_order_args(name: &'static str) -> clap::Command {
329+
clap::Command::new(name)
330+
.arg(clap::Arg::new("1st").help("1st"))
331+
.arg(clap::Arg::new("2nd").help("2nd"))
332+
.arg(clap::Arg::new("3rd").help("3rd").last(true))
333+
.arg(
334+
clap::Arg::new("c")
335+
.long("third")
336+
.short('Q')
337+
.display_order(3)
338+
.help("Should be 3rd"),
339+
)
340+
.arg(
341+
clap::Arg::new("d")
342+
.long("fourth")
343+
.display_order(4)
344+
.help("Should be 4th"),
345+
)
346+
.arg(
347+
clap::Arg::new("a")
348+
.long("first")
349+
.short('O')
350+
.display_order(1)
351+
.help("Should be 1st"),
352+
)
353+
.arg(
354+
clap::Arg::new("b")
355+
.long("second")
356+
.short('P')
357+
.display_order(2)
358+
.help("Should be 2nd"),
359+
)
360+
361+
}
362+
363+
327364
pub(crate) fn help_headings(name: &'static str) -> clap::Command {
328365
clap::Command::new(name)
329366
.arg(

clap_mangen/tests/testsuite/roff.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,14 @@ fn value_name_without_arg() {
112112
cmd,
113113
);
114114
}
115+
116+
#[test]
117+
fn configured_display_order_args() {
118+
let name = "my-app";
119+
let cmd = common::configured_display_order_args(name);
120+
121+
common::assert_matches(
122+
snapbox::file!["../snapshots/configured_display_order_args.roff"],
123+
cmd,
124+
);
125+
}

0 commit comments

Comments
 (0)