-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathhello.js
More file actions
30 lines (25 loc) · 701 Bytes
/
Copy pathhello.js
File metadata and controls
30 lines (25 loc) · 701 Bytes
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
#!/usr/bin/env node
/*
* The smallest example using dashdash for option processing.
*/
var dashdash = require('../lib/dashdash');
// Define your options.
var options = [
{
names: ['verbose', 'v'], // first name is opts key
type: 'bool',
help: 'More verbose output.'
}
];
// Shortcut to create parser and parse `process.argv` in one step.
try {
var opts = dashdash.parse({options: options});
} catch (e) {
console.error('hello: error: %s', e.message);
process.exit(1);
}
if (opts.verbose) {
console.log("# opts:", opts);
console.log("# args:", opts._args);
}
// See "help.js" for a small example that uses generated option help output.