Files
Charlie Root 58f2e80eb5 update
2022-07-31 09:56:11 +00:00

17 lines
729 B
JavaScript

// node-getopt oneline example.
opt = require('..').create([
['s' , '' , 'short option.'],
['' , 'long' , 'long option.'],
['S' , 'short-with-arg=ARG' , 'option with argument', 'S'],
['L' , 'long-with-arg=ARG' , 'long option with argument'],
['' , 'color[=COLOR]' , 'COLOR is optional'],
['m' , 'multi-with-arg=ARG+' , 'multiple option with argument'],
['' , 'no-comment'],
['h' , 'help' , 'display this help'],
['v' , 'version' , 'show version']
]) // create Getopt instance
.bindHelp() // bind option 'help' to default action
.parseSystem(); // parse command line
console.info({argv: opt.argv, options: opt.options});