File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ // const commander = require('commander'); // (normal include)
2
+ const commander = require ( '../' ) ; // include commander in git clone of commander repo
3
+
4
+ // By default the subcommand list includes a fairly simple usage. If you have added a custom usage
5
+ // to the subcommands you may wish to configure the help to show these instead.
6
+ //
7
+ // See also ./configure-help.js which shows configuring the subcommand list to have no usage at all
8
+ // and just the subcommand name.
9
+
10
+ const program = new commander . Command ( )
11
+ . configureHelp ( { subcommandTerm : ( cmd ) => cmd . name ( ) + ' ' + cmd . usage ( ) } ) ;
12
+
13
+ program . command ( 'make <FILENAME>' )
14
+ . usage ( '-root ROOTDIR [-abc] <FILENAME>' )
15
+ . requiredOption ( '--root <ROOTDIR>' )
16
+ . option ( '-a' )
17
+ . option ( '-b' )
18
+ . option ( '-c' )
19
+ . summary ( 'example command with custom usage' )
20
+ . description ( 'this full description is displayed in the full help and not in the list of subcommands' ) ;
21
+
22
+ program . command ( 'serve <SERVICE>' )
23
+ . option ( '--port <PORTNUMBER>' )
24
+ . description ( 'example command with default simple usage' ) ;
25
+
26
+ program . parse ( ) ;
27
+
28
+ // Try the following:
29
+ // node help-subcommands-usage help
You can’t perform that action at this time.
0 commit comments