File tree Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Original file line number Diff line number Diff line change
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
+ \fB my \- 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 ] [\fI 1st \fR ] [\fI 2nd \fR ] [\fI 3rd \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
+ [\fI 1st \fR ]
27
+ 1st
28
+ .TP
29
+ [\fI 2nd \fR ]
30
+ 2nd
31
+ .TP
32
+ [\fI 3rd \fR ]
33
+ 3rd
Original file line number Diff line number Diff line change @@ -324,6 +324,43 @@ pub(crate) fn value_name_without_arg(name: &'static str) -> clap::Command {
324
324
)
325
325
}
326
326
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
+
327
364
pub ( crate ) fn help_headings ( name : & ' static str ) -> clap:: Command {
328
365
clap:: Command :: new ( name)
329
366
. arg (
Original file line number Diff line number Diff line change @@ -112,3 +112,14 @@ fn value_name_without_arg() {
112
112
cmd,
113
113
) ;
114
114
}
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
+ }
You can’t perform that action at this time.
0 commit comments