yargs 1.3.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -30
- package/index.js +99 -71
- package/lib/{minimist.js → parser.js} +93 -38
- package/package.json +46 -6
- package/.npmignore +0 -3
- package/.travis.yml +0 -3
- package/example/bool.js +0 -10
- package/example/boolean_double.js +0 -7
- package/example/boolean_single.js +0 -7
- package/example/count.js +0 -15
- package/example/default_hash.js +0 -8
- package/example/default_singles.js +0 -7
- package/example/demand_count.js +0 -5
- package/example/divide.js +0 -8
- package/example/help.js +0 -27
- package/example/implies.js +0 -10
- package/example/implies_hash.js +0 -26
- package/example/line_count.js +0 -20
- package/example/line_count_options.js +0 -29
- package/example/line_count_wrap.js +0 -29
- package/example/nonopt.js +0 -4
- package/example/requires_arg.js +0 -19
- package/example/short.js +0 -3
- package/example/strict.js +0 -19
- package/example/string.js +0 -11
- package/example/usage-options.js +0 -19
- package/example/xup.js +0 -9
- package/lib/wordwrap.js +0 -50
- package/test/_/bin.js +0 -3
- package/test/_.js +0 -64
- package/test/config.json +0 -5
- package/test/count.js +0 -28
- package/test/dash.js +0 -35
- package/test/mocha.opts +0 -1
- package/test/parse.js +0 -355
- package/test/parse_camelCase.js +0 -129
- package/test/parse_defaults.js +0 -82
- package/test/parse_modified.js +0 -21
- package/test/short.js +0 -20
- package/test/usage.js +0 -747
- package/test/whitespace.js +0 -12
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// fancy-pants parsing of argv, originally forked
|
|
2
|
+
// from minimist: https://www.npmjs.com/package/minimist
|
|
1
3
|
var path = require('path');
|
|
2
4
|
var fs = require('fs');
|
|
3
5
|
|
|
@@ -32,13 +34,17 @@ module.exports = function (args, opts) {
|
|
|
32
34
|
}).join('');
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
var aliases = {}
|
|
37
|
+
var aliases = {},
|
|
38
|
+
newAliases = {};
|
|
39
|
+
|
|
36
40
|
Object.keys(opts.alias || {}).forEach(function (key) {
|
|
37
41
|
aliases[key] = [].concat(opts.alias[key]);
|
|
38
42
|
// For "--option-name", also set argv.optionName
|
|
39
43
|
aliases[key].concat(key).forEach(function (x) {
|
|
40
44
|
if (/-/.test(x)) {
|
|
41
|
-
|
|
45
|
+
var c = toCamelCase(x);
|
|
46
|
+
aliases[key].push(c);
|
|
47
|
+
newAliases[c] = true;
|
|
42
48
|
}
|
|
43
49
|
});
|
|
44
50
|
aliases[key].forEach(function (x) {
|
|
@@ -52,7 +58,13 @@ module.exports = function (args, opts) {
|
|
|
52
58
|
|
|
53
59
|
Object.keys(defaults || {}).forEach(function (key) {
|
|
54
60
|
if (/-/.test(key) && !opts.alias[key]) {
|
|
55
|
-
|
|
61
|
+
var c = toCamelCase(key);
|
|
62
|
+
aliases[key] = aliases[key] || [];
|
|
63
|
+
// don't allow the same key to be added multiple times.
|
|
64
|
+
if (aliases[key].indexOf(c) === -1) {
|
|
65
|
+
aliases[key] = (aliases[key] || []).concat(c);
|
|
66
|
+
newAliases[c] = true;
|
|
67
|
+
}
|
|
56
68
|
}
|
|
57
69
|
(aliases[key] || []).forEach(function (alias) {
|
|
58
70
|
defaults[alias] = defaults[key];
|
|
@@ -61,19 +73,25 @@ module.exports = function (args, opts) {
|
|
|
61
73
|
|
|
62
74
|
var argv = { _ : [] };
|
|
63
75
|
Object.keys(flags.bools).forEach(function (key) {
|
|
64
|
-
setArg(key,
|
|
76
|
+
setArg(key, !(key in defaults) ? false : defaults[key]);
|
|
65
77
|
});
|
|
66
78
|
|
|
67
79
|
var notFlags = [];
|
|
68
|
-
|
|
69
80
|
if (args.indexOf('--') !== -1) {
|
|
70
81
|
notFlags = args.slice(args.indexOf('--')+1);
|
|
71
82
|
args = args.slice(0, args.indexOf('--'));
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
function setArg (key, val) {
|
|
86
|
+
// handle parsing boolean arguments --foo=true --bar false.
|
|
87
|
+
if (flags.bools[key] || (aliases[key] ? flags.bools[aliases[key]] : false)) {
|
|
88
|
+
if (typeof val === 'string') val = val === 'true';
|
|
89
|
+
}
|
|
90
|
+
|
|
75
91
|
if (/-/.test(key) && !(aliases[key] && aliases[key].length)) {
|
|
76
|
-
|
|
92
|
+
var c = toCamelCase(key);
|
|
93
|
+
aliases[key] = [c];
|
|
94
|
+
newAliases[c] = true;
|
|
77
95
|
}
|
|
78
96
|
|
|
79
97
|
var value = !flags.strings[key] && isNumber(val) ? Number(val) : val;
|
|
@@ -82,18 +100,6 @@ module.exports = function (args, opts) {
|
|
|
82
100
|
value = function(orig) { return orig !== undefined ? orig + 1 : 0; };
|
|
83
101
|
}
|
|
84
102
|
|
|
85
|
-
if (flags.configs[key]) {
|
|
86
|
-
try {
|
|
87
|
-
var config = JSON.parse(fs.readFileSync(val, 'utf8'));
|
|
88
|
-
Object.keys(config).forEach(function (key) {
|
|
89
|
-
setArg(key, config[key]);
|
|
90
|
-
});
|
|
91
|
-
} catch (ex) {
|
|
92
|
-
console.error('Invalid JSON config file: ' + val);
|
|
93
|
-
throw ex;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
103
|
setKey(argv, key.split('.'), value);
|
|
98
104
|
|
|
99
105
|
(aliases[key] || []).forEach(function (x) {
|
|
@@ -118,6 +124,35 @@ module.exports = function (args, opts) {
|
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
|
|
127
|
+
// set args from config.json file, this should be
|
|
128
|
+
// applied last so that defaults can be applied.
|
|
129
|
+
function setConfig (argv) {
|
|
130
|
+
var configLookup = {};
|
|
131
|
+
|
|
132
|
+
// expand defaults/aliases, in-case any happen to reference
|
|
133
|
+
// the config.json file.
|
|
134
|
+
applyDefaultsAndAliases(configLookup, aliases, defaults);
|
|
135
|
+
|
|
136
|
+
Object.keys(flags.configs).forEach(function(configKey) {
|
|
137
|
+
var configPath = argv[configKey] || configLookup[configKey];
|
|
138
|
+
if (configPath) {
|
|
139
|
+
try {
|
|
140
|
+
var config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
141
|
+
Object.keys(config).forEach(function (key) {
|
|
142
|
+
// setting arguments via CLI takes precedence over
|
|
143
|
+
// values within the config file.
|
|
144
|
+
if (argv[key] === undefined) {
|
|
145
|
+
delete argv[key];
|
|
146
|
+
setArg(key, config[key]);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
} catch (ex) {
|
|
150
|
+
throw Error('invalid json config file: ' + configPath);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
121
156
|
for (var i = 0; i < args.length; i++) {
|
|
122
157
|
var arg = args[i];
|
|
123
158
|
|
|
@@ -142,11 +177,11 @@ module.exports = function (args, opts) {
|
|
|
142
177
|
i++;
|
|
143
178
|
}
|
|
144
179
|
else if (/^(true|false)$/.test(next)) {
|
|
145
|
-
setArg(key, next
|
|
180
|
+
setArg(key, next);
|
|
146
181
|
i++;
|
|
147
182
|
}
|
|
148
183
|
else {
|
|
149
|
-
setArg(key,
|
|
184
|
+
setArg(key, defaultForType(guessType(key, flags)));
|
|
150
185
|
}
|
|
151
186
|
}
|
|
152
187
|
else if (arg.match(/^-[^-]+/)) {
|
|
@@ -180,7 +215,7 @@ module.exports = function (args, opts) {
|
|
|
180
215
|
break;
|
|
181
216
|
}
|
|
182
217
|
else {
|
|
183
|
-
setArg(letters[j],
|
|
218
|
+
setArg(letters[j], defaultForType(guessType(letters[j], flags)));
|
|
184
219
|
}
|
|
185
220
|
}
|
|
186
221
|
|
|
@@ -193,11 +228,11 @@ module.exports = function (args, opts) {
|
|
|
193
228
|
i++;
|
|
194
229
|
}
|
|
195
230
|
else if (args[i+1] && /true|false/.test(args[i+1])) {
|
|
196
|
-
setArg(key, args[i+1]
|
|
231
|
+
setArg(key, args[i+1]);
|
|
197
232
|
i++;
|
|
198
233
|
}
|
|
199
234
|
else {
|
|
200
|
-
setArg(key,
|
|
235
|
+
setArg(key, defaultForType(guessType(key, flags)));
|
|
201
236
|
}
|
|
202
237
|
}
|
|
203
238
|
}
|
|
@@ -208,15 +243,8 @@ module.exports = function (args, opts) {
|
|
|
208
243
|
}
|
|
209
244
|
}
|
|
210
245
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
setKey(argv, key.split('.'), defaults[key]);
|
|
214
|
-
|
|
215
|
-
(aliases[key] || []).forEach(function (x) {
|
|
216
|
-
setKey(argv, x.split('.'), defaults[key]);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
});
|
|
246
|
+
setConfig(argv);
|
|
247
|
+
applyDefaultsAndAliases(argv, aliases, defaults);
|
|
220
248
|
|
|
221
249
|
Object.keys(flags.counts).forEach(function (key) {
|
|
222
250
|
setArg(key, defaults[key]);
|
|
@@ -228,10 +256,23 @@ module.exports = function (args, opts) {
|
|
|
228
256
|
|
|
229
257
|
return {
|
|
230
258
|
argv: argv,
|
|
231
|
-
aliases: aliases
|
|
259
|
+
aliases: aliases,
|
|
260
|
+
newAliases: newAliases
|
|
232
261
|
};
|
|
233
262
|
};
|
|
234
263
|
|
|
264
|
+
function applyDefaultsAndAliases(obj, aliases, defaults) {
|
|
265
|
+
Object.keys(defaults).forEach(function (key) {
|
|
266
|
+
if (!hasKey(obj, key.split('.'))) {
|
|
267
|
+
setKey(obj, key.split('.'), defaults[key]);
|
|
268
|
+
|
|
269
|
+
(aliases[key] || []).forEach(function (x) {
|
|
270
|
+
setKey(obj, x.split('.'), defaults[key]);
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
235
276
|
function hasKey (obj, keys) {
|
|
236
277
|
var o = obj;
|
|
237
278
|
keys.slice(0,-1).forEach(function (key) {
|
|
@@ -249,7 +290,6 @@ function setKey (obj, keys, value) {
|
|
|
249
290
|
o = o[key];
|
|
250
291
|
});
|
|
251
292
|
|
|
252
|
-
|
|
253
293
|
var key = keys[keys.length - 1];
|
|
254
294
|
if (typeof value === 'function') {
|
|
255
295
|
o[key] = value(o[key]);
|
|
@@ -265,12 +305,27 @@ function setKey (obj, keys, value) {
|
|
|
265
305
|
}
|
|
266
306
|
}
|
|
267
307
|
|
|
308
|
+
// return a default value, given the type of a flag.,
|
|
309
|
+
// e.g., key of type 'string' will default to '', rather than 'true'.
|
|
310
|
+
function defaultForType (type) {
|
|
311
|
+
var def = {
|
|
312
|
+
boolean: true,
|
|
313
|
+
string: ''
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
return def[type];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// given a flag, enforce a default type.
|
|
320
|
+
function guessType (key, flags) {
|
|
321
|
+
var type = 'boolean';
|
|
322
|
+
if (flags.strings && flags.strings[key]) type = 'string';
|
|
323
|
+
|
|
324
|
+
return type;
|
|
325
|
+
}
|
|
326
|
+
|
|
268
327
|
function isNumber (x) {
|
|
269
328
|
if (typeof x === 'number') return true;
|
|
270
329
|
if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
|
271
330
|
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
|
272
331
|
}
|
|
273
|
-
|
|
274
|
-
function longest (xs) {
|
|
275
|
-
return Math.max.apply(null, xs.map(function (x) { return x.length }));
|
|
276
|
-
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Light-weight option parsing with an argv hash. No optstrings attached.",
|
|
5
5
|
"main": "./index.js",
|
|
6
|
-
"
|
|
6
|
+
"files": [
|
|
7
|
+
"index.js",
|
|
8
|
+
"lib",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"wordwrap": "0.0.2"
|
|
13
|
+
},
|
|
7
14
|
"devDependencies": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
15
|
+
"blanket": "^1.1.6",
|
|
16
|
+
"chai": "^1.10.0",
|
|
17
|
+
"coveralls": "^2.11.2",
|
|
18
|
+
"hashish": "0.0.4",
|
|
19
|
+
"mocha": "^2.1.0",
|
|
20
|
+
"mocha-lcov-reporter": "0.0.1",
|
|
21
|
+
"mocoverage": "^1.0.0"
|
|
11
22
|
},
|
|
12
23
|
"scripts": {
|
|
13
|
-
"test": "mocha -R
|
|
24
|
+
"test": "mocha --check-leaks --ui exports --require blanket -R mocoverage"
|
|
14
25
|
},
|
|
15
26
|
"repository": {
|
|
16
27
|
"type": "git",
|
|
17
28
|
"url": "http://github.com/chevex/yargs.git"
|
|
18
29
|
},
|
|
30
|
+
"config": {
|
|
31
|
+
"blanket": {
|
|
32
|
+
"pattern": [
|
|
33
|
+
"lib",
|
|
34
|
+
"index.js"
|
|
35
|
+
],
|
|
36
|
+
"data-cover-never": [
|
|
37
|
+
"node_modules",
|
|
38
|
+
"test"
|
|
39
|
+
],
|
|
40
|
+
"output-reporter": "spec"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
19
43
|
"keywords": [
|
|
20
44
|
"argument",
|
|
21
45
|
"args",
|
|
@@ -30,6 +54,22 @@
|
|
|
30
54
|
"email": "Alex.Ford@CodeTunnel.com",
|
|
31
55
|
"url": "http://CodeTunnel.com"
|
|
32
56
|
},
|
|
57
|
+
"contributors": [
|
|
58
|
+
{
|
|
59
|
+
"name": "Chris Needham",
|
|
60
|
+
"email": "chris@chrisneedham.com",
|
|
61
|
+
"url": "http://chrisneedham.com"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "James Nylen",
|
|
65
|
+
"email": "jnylen@gmail.com",
|
|
66
|
+
"url": "https://github.com/nylen"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "Benjamin Horsleben",
|
|
70
|
+
"url": "https://github.com/fizker"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
33
73
|
"license": "MIT/X11",
|
|
34
74
|
"engine": {
|
|
35
75
|
"node": ">=0.4"
|
package/.npmignore
DELETED
package/.travis.yml
DELETED
package/example/bool.js
DELETED
package/example/count.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var argv = require('yargs')
|
|
3
|
-
.count('verbose')
|
|
4
|
-
.alias('v', 'verbose')
|
|
5
|
-
.argv;
|
|
6
|
-
|
|
7
|
-
VERBOSE_LEVEL = argv.verbose;
|
|
8
|
-
|
|
9
|
-
function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); }
|
|
10
|
-
function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); }
|
|
11
|
-
function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); }
|
|
12
|
-
|
|
13
|
-
WARN("Showing only important stuff");
|
|
14
|
-
INFO("Showing semi-important stuff too");
|
|
15
|
-
DEBUG("Extra chatty mode");
|
package/example/default_hash.js
DELETED
package/example/demand_count.js
DELETED
package/example/divide.js
DELETED
package/example/help.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var yargs = require('../index');
|
|
2
|
-
|
|
3
|
-
var argv = yargs
|
|
4
|
-
.usage('This is my awesome program\n\nUsage: $0 [options]')
|
|
5
|
-
.help('help').alias('help', 'h')
|
|
6
|
-
.version('1.0.1', 'version').alias('version', 'V')
|
|
7
|
-
.options({
|
|
8
|
-
input: {
|
|
9
|
-
alias: 'i',
|
|
10
|
-
description: "<filename> Input file name",
|
|
11
|
-
requiresArg: true,
|
|
12
|
-
required: true
|
|
13
|
-
},
|
|
14
|
-
output: {
|
|
15
|
-
alias: 'o',
|
|
16
|
-
description: "<filename> output file name",
|
|
17
|
-
requiresArg: true,
|
|
18
|
-
required: true
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
.argv;
|
|
22
|
-
|
|
23
|
-
console.log('Inspecting options');
|
|
24
|
-
console.dir(argv);
|
|
25
|
-
|
|
26
|
-
console.log("input:", argv.input);
|
|
27
|
-
console.log("output:", argv.output);
|
package/example/implies.js
DELETED
package/example/implies_hash.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var argv = require('yargs')
|
|
4
|
-
.usage('Usage: $0 -x [num] -y [num] -w [msg] -h [msg]')
|
|
5
|
-
.implies({
|
|
6
|
-
x: 'y',
|
|
7
|
-
w: '--no-h',
|
|
8
|
-
1: 'h'
|
|
9
|
-
})
|
|
10
|
-
.argv;
|
|
11
|
-
|
|
12
|
-
if (argv.x) {
|
|
13
|
-
console.log('x / y : ' + (argv.x / argv.y));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (argv.y) {
|
|
17
|
-
console.log('y: ' + argv.y);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (argv.w) {
|
|
21
|
-
console.log('w: ' +argv.w);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (argv.h) {
|
|
25
|
-
console.log('h: ' +argv.h);
|
|
26
|
-
}
|
package/example/line_count.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var argv = require('yargs')
|
|
3
|
-
.usage('Count the lines in a file.\nUsage: $0')
|
|
4
|
-
.demand('f')
|
|
5
|
-
.alias('f', 'file')
|
|
6
|
-
.describe('f', 'Load a file')
|
|
7
|
-
.argv
|
|
8
|
-
;
|
|
9
|
-
|
|
10
|
-
var fs = require('fs');
|
|
11
|
-
var s = fs.createReadStream(argv.file);
|
|
12
|
-
|
|
13
|
-
var lines = 0;
|
|
14
|
-
s.on('data', function (buf) {
|
|
15
|
-
lines += buf.toString().match(/\n/g).length;
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
s.on('end', function () {
|
|
19
|
-
console.log(lines);
|
|
20
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var argv = require('yargs')
|
|
3
|
-
.usage('Count the lines in a file.\nUsage: $0')
|
|
4
|
-
.options({
|
|
5
|
-
file : {
|
|
6
|
-
demand : true,
|
|
7
|
-
alias : 'f',
|
|
8
|
-
description : 'Load a file'
|
|
9
|
-
},
|
|
10
|
-
base : {
|
|
11
|
-
alias : 'b',
|
|
12
|
-
description : 'Numeric base to use for output',
|
|
13
|
-
default : 10,
|
|
14
|
-
},
|
|
15
|
-
})
|
|
16
|
-
.argv
|
|
17
|
-
;
|
|
18
|
-
|
|
19
|
-
var fs = require('fs');
|
|
20
|
-
var s = fs.createReadStream(argv.file);
|
|
21
|
-
|
|
22
|
-
var lines = 0;
|
|
23
|
-
s.on('data', function (buf) {
|
|
24
|
-
lines += buf.toString().match(/\n/g).length;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
s.on('end', function () {
|
|
28
|
-
console.log(lines.toString(argv.base));
|
|
29
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var argv = require('yargs')
|
|
3
|
-
.usage('Count the lines in a file.\nUsage: $0')
|
|
4
|
-
.wrap(80)
|
|
5
|
-
.demand('f')
|
|
6
|
-
.alias('f', [ 'file', 'filename' ])
|
|
7
|
-
.describe('f',
|
|
8
|
-
"Load a file. It's pretty important."
|
|
9
|
-
+ " Required even. So you'd better specify it."
|
|
10
|
-
)
|
|
11
|
-
.alias('b', 'base')
|
|
12
|
-
.describe('b', 'Numeric base to display the number of lines in')
|
|
13
|
-
.default('b', 10)
|
|
14
|
-
.describe('x', 'Super-secret optional parameter which is secret')
|
|
15
|
-
.default('x', '')
|
|
16
|
-
.argv
|
|
17
|
-
;
|
|
18
|
-
|
|
19
|
-
var fs = require('fs');
|
|
20
|
-
var s = fs.createReadStream(argv.file);
|
|
21
|
-
|
|
22
|
-
var lines = 0;
|
|
23
|
-
s.on('data', function (buf) {
|
|
24
|
-
lines += buf.toString().match(/\n/g).length;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
s.on('end', function () {
|
|
28
|
-
console.log(lines.toString(argv.base));
|
|
29
|
-
});
|
package/example/nonopt.js
DELETED
package/example/requires_arg.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var yargs = require('yargs');
|
|
2
|
-
|
|
3
|
-
var argv = yargs.usage('This is my awesome program', {
|
|
4
|
-
'input': {
|
|
5
|
-
description: 'Input file name',
|
|
6
|
-
requiresArg: true,
|
|
7
|
-
short: 'i',
|
|
8
|
-
},
|
|
9
|
-
'output': {
|
|
10
|
-
description: 'Output file name',
|
|
11
|
-
requiresArg: true,
|
|
12
|
-
short: 'o'
|
|
13
|
-
}
|
|
14
|
-
}).argv;
|
|
15
|
-
|
|
16
|
-
yargs.showHelp();
|
|
17
|
-
|
|
18
|
-
console.log('\n\nInspecting options');
|
|
19
|
-
console.dir(argv);
|
package/example/short.js
DELETED
package/example/strict.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var yargs = require('yargs');
|
|
2
|
-
|
|
3
|
-
var argv = yargs.usage('This is my awesome program', {
|
|
4
|
-
'about': {
|
|
5
|
-
description: 'Provide some details about the author of this program',
|
|
6
|
-
boolean: true,
|
|
7
|
-
short: 'a',
|
|
8
|
-
},
|
|
9
|
-
'info': {
|
|
10
|
-
description: 'Provide some information about this program',
|
|
11
|
-
boolean: true,
|
|
12
|
-
short: 'i'
|
|
13
|
-
}
|
|
14
|
-
}).strict().argv;
|
|
15
|
-
|
|
16
|
-
yargs.showHelp();
|
|
17
|
-
|
|
18
|
-
console.log('\n\nInspecting options');
|
|
19
|
-
console.dir(argv);
|
package/example/string.js
DELETED
package/example/usage-options.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
var yargs = require('yargs');
|
|
2
|
-
|
|
3
|
-
var argv = yargs.usage('This is my awesome program', {
|
|
4
|
-
'about': {
|
|
5
|
-
description: 'Provide some details about the author of this program',
|
|
6
|
-
required: true,
|
|
7
|
-
alias: 'a',
|
|
8
|
-
},
|
|
9
|
-
'info': {
|
|
10
|
-
description: 'Provide some information about the node.js agains!!!!!!',
|
|
11
|
-
boolean: true,
|
|
12
|
-
alias: 'i'
|
|
13
|
-
}
|
|
14
|
-
}).argv;
|
|
15
|
-
|
|
16
|
-
yargs.showHelp();
|
|
17
|
-
|
|
18
|
-
console.log('\n\nInspecting options');
|
|
19
|
-
console.dir(argv);
|