@@ -2599,6 +2599,32 @@ describe('usage tests', () => {
2599
2599
] )
2600
2600
} )
2601
2601
2602
+ it ( 'should display top-level help with sorting with no command given if sorting enabled' , ( ) => {
2603
+ const r = checkUsage ( ( ) => yargs ( '--help' )
2604
+ . command ( [ 'list [pattern]' , 'ls' , '*' ] , 'List key-value pairs for pattern' , { } , noop )
2605
+ . command ( 'get <key>' , 'Get value for key' , { } , noop )
2606
+ . command ( 'set <key> [value]' , 'Set value for key' , { } , noop )
2607
+ . parserConfiguration ( { 'sort-commands' : true } )
2608
+ . parse ( )
2609
+ )
2610
+
2611
+ r . logs [ 0 ] . split ( '\n' ) . should . deep . equal ( [
2612
+ 'usage [pattern]' ,
2613
+ '' ,
2614
+ 'List key-value pairs for pattern' ,
2615
+ '' ,
2616
+ 'Commands:' ,
2617
+ ' usage get <key> Get value for key' ,
2618
+ ' usage list [pattern] List key-value pairs for pattern' ,
2619
+ ' [default] [aliases: ls]' ,
2620
+ ' usage set <key> [value] Set value for key' ,
2621
+ '' ,
2622
+ 'Options:' ,
2623
+ ' --help Show help [boolean]' ,
2624
+ ' --version Show version number [boolean]'
2625
+ ] )
2626
+ } )
2627
+
2602
2628
it ( 'should display default command as ./$0 if it has no aliases' , ( ) => {
2603
2629
const r = checkUsage ( ( ) => yargs ( '--help' )
2604
2630
. command ( '* [pattern]' , 'List key-value pairs for pattern' , { } , noop )
0 commit comments