mirror of
https://github.com/outbackdingo/control-pane.git
synced 2026-02-07 09:40:26 +00:00
23 lines
603 B
JavaScript
23 lines
603 B
JavaScript
// examples/simple.js
|
|
// argv parse
|
|
Getopt = require('..');
|
|
|
|
// Getopt arguments options
|
|
// '=': has argument
|
|
// '[=]': has argument but optional
|
|
// '+': multiple option supported
|
|
getopt = new Getopt([
|
|
['s'],
|
|
['S' , '='],
|
|
['' , 'long-with-arg=ARG'],
|
|
['m' , '=+'],
|
|
['' , 'color[=COLOR]'],
|
|
['h' , 'help']
|
|
]).bindHelp();
|
|
|
|
// process.argv needs slice(2) for it starts with 'node' and 'script name'
|
|
// parseSystem is alias of parse(process.argv.slice(2))
|
|
// opt = getopt.parseSystem();
|
|
opt = getopt.parse(process.argv.slice(2));
|
|
console.info({argv: opt.argv, options: opt.options});
|