-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathhelp-subcommands-usage.js
33 lines (27 loc) · 1022 Bytes
/
help-subcommands-usage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const commander = require('commander');
// By default the subcommand list includes a fairly simple usage. If you have added a custom usage
// to the subcommands you may wish to configure the help to show these instead.
//
// See also ./configure-help.js which shows configuring the subcommand list to have no usage at all
// and just the subcommand name.
const program = new commander.Command().configureHelp({
subcommandTerm: (cmd) => cmd.name() + ' ' + cmd.usage(),
});
program
.command('make <FILENAME>')
.usage('-root ROOTDIR [-abc] <FILENAME>')
.requiredOption('--root <ROOTDIR>')
.option('-a')
.option('-b')
.option('-c')
.summary('example command with custom usage')
.description(
'this full description is displayed in the full help and not in the list of subcommands',
);
program
.command('serve <SERVICE>')
.option('--port <PORTNUMBER>')
.description('example command with default simple usage');
program.parse();
// Try the following:
// node help-subcommands-usage help