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/lib/wordwrap.js DELETED
@@ -1,50 +0,0 @@
1
- // Simplified version of https://github.com/substack/node-wordwrap
2
-
3
- 'use strict';
4
-
5
- module.exports = function (start, stop) {
6
-
7
- if (!stop) {
8
- stop = start;
9
- start = 0;
10
- }
11
-
12
- var re = /(\S+\s+)/;
13
-
14
- return function (text) {
15
- var chunks = text.toString().split(re);
16
-
17
- return chunks.reduce(function (lines, rawChunk) {
18
- if (rawChunk === '') return lines;
19
-
20
- var chunk = rawChunk.replace(/\t/g, ' ');
21
-
22
- var i = lines.length - 1;
23
- if (lines[i].length + chunk.length > stop) {
24
- lines[i] = lines[i].replace(/\s+$/, '');
25
-
26
- chunk.split(/\n/).forEach(function (c) {
27
- lines.push(
28
- new Array(start + 1).join(' ')
29
- + c.replace(/^\s+/, '')
30
- );
31
- });
32
- }
33
- else if (chunk.match(/\n/)) {
34
- var xs = chunk.split(/\n/);
35
- lines[i] += xs.shift();
36
- xs.forEach(function (c) {
37
- lines.push(
38
- new Array(start + 1).join(' ')
39
- + c.replace(/^\s+/, '')
40
- );
41
- });
42
- }
43
- else {
44
- lines[i] += chunk;
45
- }
46
-
47
- return lines;
48
- }, [ new Array(start + 1).join(' ') ]).join('\n');
49
- };
50
- };
package/test/_/bin.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- var argv = require('../../index').argv
3
- console.log(JSON.stringify(argv._));
package/test/_.js DELETED
@@ -1,64 +0,0 @@
1
- var spawn = require('child_process').spawn,
2
- should = require('chai').should();
3
-
4
- describe('bin script', function () {
5
-
6
- it('should run as a shell script with no arguments', function (done) {
7
- testCmd('./bin.js', [], done);
8
- });
9
-
10
- it('should run as a shell script with arguments', function (done) {
11
- testCmd('./bin.js', [ 'a', 'b', 'c' ], done);
12
- });
13
-
14
- it('should run as a node script with no arguments', function (done) {
15
- testCmd('node bin.js', [], done);
16
- });
17
-
18
- it('should run as a node script with arguments', function (done) {
19
- testCmd('node bin.js', [ 'x', 'y', 'z' ], done);
20
- });
21
-
22
- describe('path returned by "which"', function () {
23
-
24
- beforeEach(function () {
25
- this.which = spawn('which', ['node']);
26
- });
27
-
28
- it('should match the actual path to the script file', function (done) {
29
- this.which.stdout.on('data', function (buf) {
30
- testCmd(buf.toString().trim() + ' bin.js', [], done);
31
- });
32
- this.which.stderr.on('data', done);
33
- });
34
-
35
- it('should match the actual path to the script file, with arguments', function (done) {
36
- this.which.stdout.on('data', function (buf) {
37
- testCmd(buf.toString().trim() + ' bin.js', [ 'q', 'r' ], done);
38
- });
39
- this.which.stderr.on('data', done);
40
- });
41
-
42
- });
43
-
44
- });
45
-
46
- function testCmd(cmd, args, done) {
47
-
48
- var oldDir = process.cwd();
49
- process.chdir(__dirname + '/_');
50
-
51
- var cmds = cmd.split(' ');
52
-
53
- var bin = spawn(cmds[0], cmds.slice(1).concat(args.map(String)));
54
- process.chdir(oldDir);
55
-
56
- bin.stderr.on('data', done);
57
-
58
- bin.stdout.on('data', function (buf) {
59
- var _ = JSON.parse(buf.toString());
60
- _.map(String).should.deep.equal(args.map(String));
61
- done();
62
- });
63
-
64
- }
package/test/config.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "herp": "derp",
3
- "z": 55,
4
- "foo": "baz"
5
- }
package/test/count.js DELETED
@@ -1,28 +0,0 @@
1
- var should = require('chai').should()
2
- yargs = require('../index');
3
-
4
- describe('count', function () {
5
-
6
- it('should count the number of times a boolean is present', function () {
7
- var parsed;
8
-
9
- parsed = yargs(['-x']).count('verbose').argv;
10
- parsed.verbose.should.equal(0);
11
-
12
- parsed = yargs(['--verbose']).count('verbose').argv;
13
- parsed.verbose.should.equal(1);
14
-
15
- parsed = yargs(['--verbose', '--verbose']).count('verbose').argv;
16
- parsed.verbose.should.equal(2);
17
-
18
- parsed = yargs(['-vvv']).alias('v', 'verbose').count('verbose').argv;
19
- parsed.verbose.should.equal(3);
20
-
21
- parsed = yargs(['--verbose', '--verbose', '-v', '--verbose']).count('verbose').alias('v', 'verbose').argv;
22
- parsed.verbose.should.equal(4);
23
-
24
- parsed = yargs(['--verbose', '--verbose', '-v', '-vv']).count('verbose').alias('v', 'verbose').argv;
25
- parsed.verbose.should.equal(5);
26
- });
27
-
28
- });
package/test/dash.js DELETED
@@ -1,35 +0,0 @@
1
- var should = require('chai').should(),
2
- yargs = require('../index');
3
-
4
- describe('-', function () {
5
-
6
- it('should set - as value of n', function () {
7
- var argv = yargs.parse(['-n', '-']);
8
- argv.should.have.property('n', '-');
9
- argv.should.have.property('_').with.length(0);
10
- });
11
-
12
- it('should set - as a non-hyphenated value', function () {
13
- var argv = yargs.parse(['-']);
14
- argv.should.have.property('_').and.deep.equal(['-']);
15
- });
16
-
17
- it('should set - as a value of f', function () {
18
- var argv = yargs.parse(['-f-']);
19
- argv.should.have.property('f', '-');
20
- argv.should.have.property('_').with.length(0);
21
- });
22
-
23
- it('should set b to true and set - as a non-hyphenated value when b is set as a boolean', function () {
24
- var argv = yargs(['-b', '-']).boolean('b').argv;
25
- argv.should.have.property('b', true);
26
- argv.should.have.property('_').and.deep.equal(['-']);
27
- });
28
-
29
- it('should set - as the value of s when s is set as a string', function () {
30
- var argv = yargs([ '-s', '-' ]).string('s').argv;
31
- argv.should.have.property('s', '-');
32
- argv.should.have.property('_').with.length(0);
33
- });
34
-
35
- });
package/test/mocha.opts DELETED
@@ -1 +0,0 @@
1
- -R nyan
package/test/parse.js DELETED
@@ -1,355 +0,0 @@
1
- var should = require('chai').should(),
2
- yargs = require('../'),
3
- path = require('path');
4
-
5
- describe('parse', function () {
6
-
7
- it('should pass when specifying a "short boolean"', function () {
8
- var parse = yargs.parse([ '-b' ]);
9
- parse.should.have.property('b').to.be.ok.and.be.a('boolean');
10
- parse.should.have.property('_').with.length(0);
11
- });
12
-
13
- it('should pass when specifying a "long boolean"', function () {
14
- var parse = yargs.parse(['--bool']);
15
- parse.should.have.property('bool', true);
16
- parse.should.have.property('_').with.length(0);
17
- });
18
-
19
- it('should place bare options in the _ array', function () {
20
- var parse = yargs.parse(['foo', 'bar', 'baz']);
21
- parse.should.have.property('_').and.deep.equal(['foo','bar','baz']);
22
- });
23
-
24
- it('should expand grouped short options to a hash with a key for each', function () {
25
- var parse = yargs.parse(['-cats']);
26
- parse.should.have.property('c', true);
27
- parse.should.have.property('a', true);
28
- parse.should.have.property('t', true);
29
- parse.should.have.property('s', true);
30
- parse.should.have.property('_').with.length(0);
31
- });
32
-
33
- it('should set the value of the final option in a group to the next supplied value', function () {
34
- var parse = yargs.parse(['-cats', 'meow']);
35
- parse.should.have.property('c', true);
36
- parse.should.have.property('a', true);
37
- parse.should.have.property('t', true);
38
- parse.should.have.property('s', 'meow');
39
- parse.should.have.property('_').with.length(0);
40
- });
41
-
42
- it('should set the value of a single short option to the next supplied value', function () {
43
- var parse = yargs.parse(['-h', 'localhost']);
44
- parse.should.have.property('h', 'localhost');
45
- parse.should.have.property('_').with.length(0);
46
- });
47
-
48
- it('should set the value of multiple single short options to the next supplied values relative to each', function () {
49
- var parse = yargs.parse(['-h', 'localhost', '-p', '555']);
50
- parse.should.have.property('h', 'localhost');
51
- parse.should.have.property('p', 555);
52
- parse.should.have.property('_').with.length(0);
53
- });
54
-
55
- it('should set the value of a single long option to the next supplied value', function () {
56
- var parse = yargs.parse(['--pow', 'xixxle']);
57
- parse.should.have.property('pow', 'xixxle');
58
- parse.should.have.property('_').with.length(0);
59
- });
60
-
61
- it('should set the value of a single long option if an = was used', function () {
62
- var parse = yargs.parse(['--pow=xixxle']);
63
- parse.should.have.property('pow', 'xixxle');
64
- parse.should.have.property('_').with.length(0);
65
- });
66
-
67
- it('should set the value of multiple long options to the next supplied values relative to each', function () {
68
- var parse = yargs.parse(['--host', 'localhost', '--port', '555']);
69
- parse.should.have.property('host', 'localhost');
70
- parse.should.have.property('port', 555);
71
- parse.should.have.property('_').with.length(0);
72
- });
73
-
74
- it('should set the value of multiple long options if = signs were used', function () {
75
- var parse = yargs.parse(['--host=localhost', '--port=555']);
76
- parse.should.have.property('host', 'localhost');
77
- parse.should.have.property('port', 555);
78
- parse.should.have.property('_').with.length(0);
79
- });
80
-
81
- it('should still set values appropriately if a mix of short, long, and grouped short options are specified', function () {
82
- var parse = yargs.parse(['-h', 'localhost', '-fp', '555', 'script.js']);
83
- parse.should.have.property('f', true);
84
- parse.should.have.property('p', 555);
85
- parse.should.have.property('h', 'localhost');
86
- parse.should.have.property('_').and.deep.equal(['script.js']);
87
- });
88
-
89
- it('should still set values appropriately if a mix of short and long options are specified', function () {
90
- var parse = yargs.parse(['-h', 'localhost', '--port', '555']);
91
- parse.should.have.property('h', 'localhost');
92
- parse.should.have.property('port', 555);
93
- parse.should.have.property('_').with.length(0);
94
- });
95
-
96
- it('should explicitly set a boolean option to false if preceeded by "--no-"', function () {
97
- var parse = yargs.parse(['--no-moo']);
98
- parse.should.have.property('moo', false);
99
- parse.should.have.property('_').with.length(0);
100
- });
101
-
102
- it('should group values into an array if the same option is specified multiple times', function () {
103
- var parse = yargs.parse(['-v', 'a', '-v', 'b', '-v', 'c' ]);
104
- parse.should.have.property('v').and.deep.equal(['a','b','c']);
105
- parse.should.have.property('_').with.length(0);
106
- });
107
-
108
- it('should still set values appropriately if we supply a comprehensive list of various types of options', function () {
109
- var parse = yargs.parse([
110
- '--name=meowmers', 'bare', '-cats', 'woo',
111
- '-h', 'awesome', '--multi=quux',
112
- '--key', 'value',
113
- '-b', '--bool', '--no-meep', '--multi=baz',
114
- '--', '--not-a-flag', 'eek'
115
- ]);
116
- parse.should.have.property('c', true);
117
- parse.should.have.property('a', true);
118
- parse.should.have.property('t', true);
119
- parse.should.have.property('s', 'woo');
120
- parse.should.have.property('h', 'awesome');
121
- parse.should.have.property('b', true);
122
- parse.should.have.property('bool', true);
123
- parse.should.have.property('key', 'value');
124
- parse.should.have.property('multi').and.deep.equal(['quux', 'baz']);
125
- parse.should.have.property('meep', false);
126
- parse.should.have.property('name', 'meowmers');
127
- parse.should.have.property('_').and.deep.equal(['bare', '--not-a-flag', 'eek']);
128
- });
129
-
130
- it('should parse numbers appropriately', function () {
131
- var argv = yargs.parse([
132
- '-x', '1234',
133
- '-y', '5.67',
134
- '-z', '1e7',
135
- '-w', '10f',
136
- '--hex', '0xdeadbeef',
137
- '789',
138
- ]);
139
- argv.should.have.property('x', 1234).and.be.a('number');
140
- argv.should.have.property('y', 5.67).and.be.a('number');
141
- argv.should.have.property('z', 1e7).and.be.a('number');
142
- argv.should.have.property('w', '10f').and.be.a('string');
143
- argv.should.have.property('hex', 0xdeadbeef).and.be.a('number');
144
- argv.should.have.property('_').and.deep.equal([789]);
145
- argv._[0].should.be.a('number');
146
- });
147
-
148
- it('should not set the next value as the value of a short option if that option is explicitly defined as a boolean', function () {
149
- var parse = yargs([ '-t', 'moo' ]).boolean(['t']).argv;
150
- parse.should.have.property('t', true).and.be.a('boolean');
151
- parse.should.have.property('_').and.deep.equal(['moo']);
152
- });
153
-
154
- it('should set boolean options values if the next value is "true" or "false"', function () {
155
- var parse = yargs(['--verbose', 'false', 'moo', '-t', 'true'])
156
- .boolean(['t', 'verbose']).default('verbose', true).argv;
157
- parse.should.have.property('verbose', false).and.be.a('boolean');
158
- parse.should.have.property('t', true).and.be.a('boolean');
159
- parse.should.have.property('_').and.deep.equal(['moo']);
160
- });
161
-
162
- it('should set boolean options to false by default', function () {
163
- var parse = yargs(['moo'])
164
- .boolean(['t', 'verbose'])
165
- .default('verbose', false)
166
- .default('t', false).argv;
167
- parse.should.have.property('verbose', false).and.be.a('boolean');
168
- parse.should.have.property('t', false).and.be.a('boolean');
169
- parse.should.have.property('_').and.deep.equal(['moo']);
170
- });
171
-
172
- it('should allow defining options as boolean in groups', function () {
173
- var parse = yargs([ '-x', '-z', 'one', 'two', 'three' ])
174
- .boolean(['x','y','z']).argv;
175
- parse.should.have.property('x', true).and.be.a('boolean');
176
- parse.should.have.property('y', false).and.be.a('boolean');
177
- parse.should.have.property('z', true).and.be.a('boolean');
178
- parse.should.have.property('_').and.deep.equal(['one','two','three']);
179
- });
180
-
181
- it('should preserve newlines in option values' , function () {
182
- var args = yargs.parse(['-s', "X\nX"]);
183
- args.should.have.property('_').with.length(0);
184
- args.should.have.property('s', 'X\nX');
185
- // reproduce in bash:
186
- // VALUE="new
187
- // line"
188
- // node program.js --s="$VALUE"
189
- args = yargs.parse(["--s=X\nX"]);
190
- args.should.have.property('_').with.length(0);
191
- args.should.have.property('s', 'X\nX');
192
- });
193
-
194
- it('should not convert numbers to type number if explicitly defined as strings' , function () {
195
- var s = yargs([ '-s', '0001234' ]).string('s').argv.s;
196
- s.should.be.a('string').and.equal('0001234');
197
- var x = yargs([ '-x', '56' ]).string('x').argv.x;
198
- x.should.be.a('string').and.equal('56');
199
- });
200
-
201
- it('should leave all non-hyphenated values as strings if _ is defined as a string', function () {
202
- var s = yargs([ ' ', ' ' ]).string('_').argv._;
203
- s.should.have.length(2);
204
- s[0].should.be.a('string').and.equal(' ');
205
- s[1].should.be.a('string').and.equal(' ');
206
- });
207
-
208
- it('should normalize redundant paths', function () {
209
- var a = yargs([ '-s', '/tmp/../' ]).alias('s', 'save').normalize('s').argv;
210
- a.should.have.property('s', '/');
211
- a.should.have.property('save', '/');
212
- });
213
-
214
- it('should normalize redundant paths when a value is later assigned', function () {
215
- var a = yargs(['-s']).normalize('s').argv;
216
- a.should.have.property('s', true);
217
- a.s = '/path/to/new/dir/../../';
218
- a.s.should.equal('/path/to/');
219
- });
220
-
221
- it('should assign data after forward slash to the option before the slash', function () {
222
- var parse = yargs.parse(['-I/foo/bar/baz']);
223
- parse.should.have.property('_').with.length(0);
224
- parse.should.have.property('I', '/foo/bar/baz');
225
- parse = yargs.parse(['-xyz/foo/bar/baz']);
226
- parse.should.have.property('x', true);
227
- parse.should.have.property('y', true);
228
- parse.should.have.property('z', '/foo/bar/baz');
229
- parse.should.have.property('_').with.length(0);
230
- });
231
-
232
- it('should set alias value to the same value as the full option', function () {
233
- var argv = yargs([ '-f', '11', '--zoom', '55' ])
234
- .alias('z', 'zoom')
235
- .argv;
236
- argv.should.have.property('zoom', 55);
237
- argv.should.have.property('z', 55);
238
- argv.should.have.property('f', 11);
239
- });
240
-
241
- /*
242
- *it('should load options and values from a file when config is used', function () {
243
- * var argv = yargs([ '--settings', '../test/config.json', '--foo', 'bar' ])
244
- * .alias('z', 'zoom')
245
- * .config('settings')
246
- * .argv;
247
- * argv.should.have.property('herp', 'derp');
248
- * argv.should.have.property('zoom', 55);
249
- * argv.should.have.property('foo').and.deep.equal(['baz','bar']);
250
- *});
251
- */
252
-
253
- it('should allow multiple aliases to be specified', function () {
254
- var argv = yargs([ '-f', '11', '--zoom', '55' ])
255
- .alias('z', [ 'zm', 'zoom' ])
256
- .argv;
257
- argv.should.have.property('zoom', 55);
258
- argv.should.have.property('z', 55);
259
- argv.should.have.property('zm', 55);
260
- argv.should.have.property('f', 11);
261
- });
262
-
263
- it('should define option as boolean and set default to true', function () {
264
- var argv = yargs.options({
265
- sometrue: {
266
- boolean: true,
267
- default: true
268
- }
269
- }).argv;
270
- argv.should.have.property('sometrue', true);
271
- });
272
-
273
- it('should define option as boolean and set default to false', function () {
274
- var argv = yargs.options({
275
- somefalse: {
276
- boolean: true,
277
- default: false
278
- }
279
- }).argv;
280
- argv.should.have.property('somefalse', false);
281
- });
282
-
283
- it('should allow object graph traversal via dot notation', function () {
284
- var argv = yargs([
285
- '--foo.bar', '3', '--foo.baz', '4',
286
- '--foo.quux.quibble', '5', '--foo.quux.o_O',
287
- '--beep.boop'
288
- ]).argv;
289
- argv.should.have.property('foo').and.deep.equal({
290
- bar: 3,
291
- baz: 4,
292
- quux: {
293
- quibble: 5,
294
- o_O: true
295
- }
296
- });
297
- argv.should.have.property('beep').and.deep.equal({ boop: true });
298
- });
299
-
300
- it('should allow booleans and aliases to be defined with chainable api', function () {
301
- var aliased = [ '-h', 'derp' ],
302
- regular = [ '--herp', 'derp' ],
303
- opts = {
304
- herp: { alias: 'h', boolean: true }
305
- },
306
- aliasedArgv = yargs(aliased).boolean('herp').alias('h', 'herp').argv,
307
- propertyArgv = yargs(regular).boolean('herp').alias('h', 'herp').argv;
308
- aliasedArgv.should.have.property('herp', true);
309
- aliasedArgv.should.have.property('h', true);
310
- aliasedArgv.should.have.property('_').and.deep.equal(['derp']);
311
- propertyArgv.should.have.property('herp', true);
312
- propertyArgv.should.have.property('h', true);
313
- propertyArgv.should.have.property('_').and.deep.equal(['derp']);
314
- });
315
-
316
- it('should allow booleans and aliases to be defined with options hash', function () {
317
- var aliased = [ '-h', 'derp' ],
318
- regular = [ '--herp', 'derp' ],
319
- opts = {
320
- herp: { alias: 'h', boolean: true }
321
- },
322
- aliasedArgv = yargs(aliased).options(opts).argv,
323
- propertyArgv = yargs(regular).options(opts).argv;
324
- aliasedArgv.should.have.property('herp', true);
325
- aliasedArgv.should.have.property('h', true);
326
- aliasedArgv.should.have.property('_').and.deep.equal(['derp']);
327
- propertyArgv.should.have.property('herp', true);
328
- propertyArgv.should.have.property('h', true);
329
- propertyArgv.should.have.property('_').and.deep.equal(['derp']);
330
- });
331
-
332
- it('should set boolean and alias using explicit true', function () {
333
- var aliased = [ '-h', 'true' ],
334
- regular = [ '--herp', 'true' ],
335
- opts = {
336
- herp: { alias: 'h', boolean: true }
337
- },
338
- aliasedArgv = yargs(aliased).boolean('h').alias('h', 'herp').argv,
339
- propertyArgv = yargs(regular).boolean('h').alias('h', 'herp').argv;
340
- aliasedArgv.should.have.property('herp', true);
341
- aliasedArgv.should.have.property('h', true);
342
- aliasedArgv.should.have.property('_').with.length(0);
343
- });
344
-
345
- // regression, see https://github.com/substack/node-optimist/issues/71
346
- it('should set boolean and --x=true', function() {
347
- var parsed = yargs(['--boool', '--other=true']).boolean('boool').argv;
348
- parsed.should.have.property('boool', true);
349
- parsed.should.have.property('other', 'true');
350
- parsed = yargs(['--boool', '--other=false']).boolean('boool').argv;
351
- parsed.should.have.property('boool', true);
352
- parsed.should.have.property('other', 'false');
353
- });
354
-
355
- });
@@ -1,129 +0,0 @@
1
- var should = require('chai').should(),
2
- yargs = require('../');
3
-
4
- describe('parse', function () {
5
-
6
- function runTests (yargs, strict) {
7
-
8
- if (!strict) {
9
- // Skip this test in strict mode because this option is not specified
10
- it('should provide options with dashes as camelCase properties', function () {
11
- var result = yargs()
12
- .parse([ '--some-option' ]);
13
-
14
- result.should.have.property('some-option').that.is.a('boolean').and.is.true;
15
- result.should.have.property('someOption' ).that.is.a('boolean').and.is.true;
16
- });
17
- }
18
-
19
- it('should provide count options with dashes as camelCase properties', function () {
20
- var result = yargs()
21
- .option('some-option', {
22
- describe : 'some option',
23
- type : 'count'
24
- })
25
- .parse([ '--some-option', '--some-option', '--some-option' ]);
26
-
27
- result.should.have.property('some-option', 3);
28
- result.should.have.property('someOption' , 3);
29
- });
30
-
31
- it('should provide options with dashes and aliases as camelCase properties', function () {
32
- var result = yargs()
33
- .option('some-option', {
34
- alias : 'o',
35
- describe : 'some option'
36
- })
37
- .parse([ '--some-option' ]);
38
-
39
- result.should.have.property('some-option').that.is.a('boolean').and.is.true;
40
- result.should.have.property('someOption' ).that.is.a('boolean').and.is.true;
41
- });
42
-
43
- it('should provide defaults of options with dashes as camelCase properties', function() {
44
- var result = yargs()
45
- .option('some-option', {
46
- describe : 'some option',
47
- default : 'asdf'
48
- })
49
- .parse([ ]);
50
-
51
- result.should.have.property('some-option', 'asdf');
52
- result.should.have.property('someOption' , 'asdf');
53
- });
54
-
55
- it('should provide aliases of options with dashes as camelCase properties', function() {
56
- var result = yargs()
57
- .option('some-option', {
58
- alias : 'o',
59
- describe : 'some option',
60
- default : 'asdf'
61
- })
62
- .parse([ ]);
63
-
64
- result.should.have.property('o', 'asdf');
65
- result.should.have.property('some-option', 'asdf');
66
- result.should.have.property('someOption' , 'asdf');
67
- });
68
-
69
- it('should provide aliases of options with dashes as camelCase properties', function() {
70
- var result = yargs()
71
- .option('o', {
72
- alias : 'some-option',
73
- describe : 'some option',
74
- default : 'asdf'
75
- })
76
- .parse([ ]);
77
-
78
- result.should.have.property('o', 'asdf');
79
- result.should.have.property('some-option', 'asdf');
80
- result.should.have.property('someOption' , 'asdf');
81
- });
82
-
83
- it('should provide aliases with dashes as camelCase properties', function() {
84
- var result = yargs()
85
- .option('o', {
86
- alias : 'some-option',
87
- describe : 'some option'
88
- })
89
- .parse([ '--some-option', 'val' ]);
90
-
91
- result.should.have.property('o' ).that.is.a('string').and.equals('val');
92
- result.should.have.property('some-option').that.is.a('string').and.equals('val');
93
- result.should.have.property('someOption' ).that.is.a('string').and.equals('val');
94
- });
95
-
96
- }
97
-
98
- describe('dashes and camelCase', function () {
99
- runTests(function() {
100
- return yargs();
101
- });
102
- });
103
-
104
- describe('dashes and camelCase (strict)', function () {
105
- runTests(function() {
106
- // Special handling for failure messages, because normally a
107
- // failure calls process.exit(1);
108
- return yargs().strict().fail(function(msg) {
109
- throw new Error(msg);
110
- });
111
- }, true);
112
-
113
- // See https://github.com/chevex/yargs/issues/31
114
-
115
- it('should not fail when options with defaults are missing', function () {
116
- var result = yargs()
117
- .fail(function(msg) {
118
- throw new Error(msg);
119
- })
120
- .option('some-option', {
121
- describe : 'some option',
122
- default : 80
123
- })
124
- .strict()
125
- .parse([ ]);
126
- });
127
- });
128
-
129
- });