@@ -324,6 +324,40 @@ pub(crate) fn value_name_without_arg(name: &'static str) -> clap::Command {
324324 )
325325}
326326
327+ pub ( crate ) fn configured_display_order_args ( name : & ' static str ) -> clap:: Command {
328+ clap:: Command :: new ( name)
329+ . arg ( clap:: Arg :: new ( "1st" ) . help ( "1st" ) )
330+ . arg ( clap:: Arg :: new ( "2nd" ) . help ( "2nd" ) )
331+ . arg ( clap:: Arg :: new ( "3rd" ) . help ( "3rd" ) . last ( true ) )
332+ . arg (
333+ clap:: Arg :: new ( "c" )
334+ . long ( "third" )
335+ . short ( 'Q' )
336+ . display_order ( 3 )
337+ . help ( "Should be 3rd" ) ,
338+ )
339+ . arg (
340+ clap:: Arg :: new ( "d" )
341+ . long ( "fourth" )
342+ . display_order ( 4 )
343+ . help ( "Should be 4th" ) ,
344+ )
345+ . arg (
346+ clap:: Arg :: new ( "a" )
347+ . long ( "first" )
348+ . short ( 'O' )
349+ . display_order ( 1 )
350+ . help ( "Should be 1st" ) ,
351+ )
352+ . arg (
353+ clap:: Arg :: new ( "b" )
354+ . long ( "second" )
355+ . short ( 'P' )
356+ . display_order ( 2 )
357+ . help ( "Should be 2nd" ) ,
358+ )
359+ }
360+
327361pub ( crate ) fn help_headings ( name : & ' static str ) -> clap:: Command {
328362 clap:: Command :: new ( name)
329363 . arg (
@@ -356,8 +390,7 @@ pub(crate) fn help_headings(name: &'static str) -> clap::Command {
356390}
357391
358392pub ( crate ) fn value_with_required_equals ( name : & ' static str ) -> clap:: Command {
359- clap:: Command :: new ( name)
360- . arg (
393+ clap:: Command :: new ( name) . arg (
361394 clap:: Arg :: new ( "config" )
362395 . long ( "config" )
363396 . value_name ( "FILE" )
@@ -367,8 +400,7 @@ pub(crate) fn value_with_required_equals(name: &'static str) -> clap::Command {
367400}
368401
369402pub ( crate ) fn optional_value_with_required_equals ( name : & ' static str ) -> clap:: Command {
370- clap:: Command :: new ( name)
371- . arg (
403+ clap:: Command :: new ( name) . arg (
372404 clap:: Arg :: new ( "config" )
373405 . long ( "config" )
374406 . value_name ( "FILE" )
@@ -379,8 +411,7 @@ pub(crate) fn optional_value_with_required_equals(name: &'static str) -> clap::C
379411}
380412
381413pub ( crate ) fn optional_value ( name : & ' static str ) -> clap:: Command {
382- clap:: Command :: new ( name)
383- . arg (
414+ clap:: Command :: new ( name) . arg (
384415 clap:: Arg :: new ( "config" )
385416 . long ( "config" )
386417 . value_name ( "FILE" )
@@ -390,8 +421,7 @@ pub(crate) fn optional_value(name: &'static str) -> clap::Command {
390421}
391422
392423pub ( crate ) fn multiple_optional_values ( name : & ' static str ) -> clap:: Command {
393- clap:: Command :: new ( name)
394- . arg (
424+ clap:: Command :: new ( name) . arg (
395425 clap:: Arg :: new ( "config" )
396426 . long ( "config" )
397427 . value_names ( [ "FILE1" , "FILE2" ] )
@@ -401,13 +431,45 @@ pub(crate) fn multiple_optional_values(name: &'static str) -> clap::Command {
401431}
402432
403433pub ( crate ) fn variadic_values ( name : & ' static str ) -> clap:: Command {
404- clap:: Command :: new ( name)
405- . arg (
434+ clap:: Command :: new ( name) . arg (
406435 clap:: Arg :: new ( "config" )
407436 . long ( "config" )
408437 . value_names ( [ "FILE1" , "FILE2" ] )
409438 . require_equals ( false )
410439 . num_args ( 3 )
411440 . help ( "Optional config file" ) ,
412441 )
413- }
442+ }
443+
444+ pub ( crate ) fn configured_subcmd_order ( name : & ' static str ) -> clap:: Command {
445+ clap:: Command :: new ( name)
446+ . version ( "1" )
447+ . next_display_order ( None )
448+ . subcommands ( vec ! [
449+ clap:: Command :: new( "b1" ) . about( "blah b1" ) . arg(
450+ clap:: Arg :: new( "test" )
451+ . short( 't' )
452+ . action( clap:: ArgAction :: SetTrue ) ,
453+ ) ,
454+ clap:: Command :: new( "a1" ) . about( "blah a1" ) . arg(
455+ clap:: Arg :: new( "roster" )
456+ . short( 'r' )
457+ . action( clap:: ArgAction :: SetTrue ) ,
458+ ) ,
459+ ] )
460+ }
461+
462+ pub ( crate ) fn default_subcmd_order ( name : & ' static str ) -> clap:: Command {
463+ clap:: Command :: new ( name) . version ( "1" ) . subcommands ( vec ! [
464+ clap:: Command :: new( "b1" ) . about( "blah b1" ) . arg(
465+ clap:: Arg :: new( "test" )
466+ . short( 't' )
467+ . action( clap:: ArgAction :: SetTrue ) ,
468+ ) ,
469+ clap:: Command :: new( "a1" ) . about( "blah a1" ) . arg(
470+ clap:: Arg :: new( "roster" )
471+ . short( 'r' )
472+ . action( clap:: ArgAction :: SetTrue ) ,
473+ ) ,
474+ ] )
475+ }
0 commit comments