yargs 4.3.2 → 4.6.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/CHANGELOG.md CHANGED
@@ -1,4 +1,55 @@
1
- ## Change Log
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ <a name="4.6.0"></a>
6
+ # [4.6.0](https://github.com/yargs/yargs/compare/v4.5.0...v4.6.0) (2016-04-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **my brand!:** I agree with [@osher](https://github.com/osher) lightweight isn't a huge selling point of ours any longer, see [#468](https://github.com/yargs/yargs/issues/468) ([c46d7e1](https://github.com/yargs/yargs/commit/c46d7e1))
12
+
13
+ ### Features
14
+
15
+ * switch to standard-version for release management ([f70f801](https://github.com/yargs/yargs/commit/f70f801))
16
+ * upgrade to version of yargs-parser that introduces some slick new features, great work [@elas7](https://github.com/elas7). update cliui, replace win-spawn, replace badge. ([#475](https://github.com/yargs/yargs/issues/475)) ([f915dd4](https://github.com/yargs/yargs/commit/f915dd4))
17
+
18
+
19
+
20
+ <a name="4.5.0"></a>
21
+ # [4.5.0](https://github.com/yargs/yargs/compare/v4.4.0...v4.5.0) (2016-04-05)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * **windows:** handle $0 better on Windows platforms ([eb6e03f](https://github.com/yargs/yargs/commit/eb6e03f))
27
+
28
+ ### Features
29
+
30
+ * **commands:** implemented variadic positional arguments ([51d926e](https://github.com/yargs/yargs/commit/51d926e))
31
+ * **completion:** completion now better handles aliases, and avoids duplicating keys. ([86416c8](https://github.com/yargs/yargs/commit/86416c8))
32
+ * **config:** If invoking .config() without parameters, set a default option ([0413dd1](https://github.com/yargs/yargs/commit/0413dd1))
33
+ * **conventional-changelog:** switching to using conventional-changelog for generating the changelog ([a2b5a2a](https://github.com/yargs/yargs/commit/a2b5a2a))
34
+
35
+
36
+
37
+ ### v4.4.0 (2016/04/03 21:10 +07:00)
38
+
39
+ - [#454](https://github.com/yargs/yargs/pull/454) fix demand() when second argument is an array (@elas7)
40
+ - [#452](https://github.com/yargs/yargs/pull/452) fix code example for `.help()` docs (@maxrimue)
41
+ - [#450](https://github.com/yargs/yargs/pull/450) fix for bash completion trailing space edge-case (@elas7)
42
+ - [#448](https://github.com/yargs/yargs/pull/448) allow a method to be passed to `showHelp`, rather than a log-level (@osher)
43
+ - [#446](https://github.com/yargs/yargs/pull/446) update yargs-parser, y18n, nyc, cliui, pkg-conf (@bcoe)
44
+ - [#436](https://github.com/yargs/yargs/pull/436) the rebase method is only used by tests, do not export it in two places (@elas7)
45
+ - [#428](https://github.com/yargs/yargs/pull/428) initial support for subcommands (@nexdrew)
46
+
47
+ ### v4.3.2 (2016/3/20 15:07 +07:00)
48
+
49
+ - [#445](https://github.com/yargs/yargs/pull/445) strict mode was failing if no commands were registered (@nexdrew)
50
+ - [#443](https://github.com/yargs/yargs/pull/443) adds Italian translation \o/ (@madrisan)
51
+ - [#441](https://github.com/yargs/yargs/pull/441) remove duplicate keys from array options configuration (@elas7)
52
+ - [#437](https://github.com/yargs/yargs/pull/437) standardize tests for .command() (@lrlna)
2
53
 
3
54
  ### v4.3.0 (2016/3/12 14:19 +07:00)
4
55
 
package/LICENSE CHANGED
@@ -1,4 +1,5 @@
1
1
  Copyright 2010 James Halliday (mail@substack.net)
2
+ Modified work Copyright 2014 Contributors (ben@npmjs.com)
2
3
 
3
4
  This project is free software released under the MIT/X11 license:
4
5
 
package/README.md CHANGED
@@ -10,7 +10,8 @@ With yargs, ye be havin' a map that leads straight to yer treasure! Treasure of
10
10
  [![Coverage Status][coveralls-image]][coveralls-url]
11
11
  [![NPM version][npm-image]][npm-url]
12
12
  [![Windows Tests][windows-image]][windows-url]
13
- [![js-standard-style][standard-image]](standard-url)
13
+ [![js-standard-style][standard-image]][standard-url]
14
+ [![standard-version][standard-version-image]][standard-version-url]
14
15
 
15
16
  > Yargs is the official successor to optimist. Please feel free to submit issues and pull requests. If you'd like to contribute and don't know where to start, have a look at [the issue list](https://github.com/yargs/yargs/issues) :)
16
17
 
@@ -454,9 +455,11 @@ var argv = require('yargs')
454
455
  ```
455
456
 
456
457
  .command(cmd, desc, [builder], [handler])
457
- -------------------
458
+ -----------------------------------------
458
459
  .command(cmd, desc, [module])
459
- -------------------
460
+ -----------------------------
461
+ .command(module)
462
+ ----------------
460
463
 
461
464
  Document the commands exposed by your application.
462
465
 
@@ -528,16 +531,33 @@ yargs.command('get <source> [proxy]', 'make a get HTTP request')
528
531
  .argv
529
532
  ```
530
533
 
534
+ #### Variadic Positional Arguments
535
+
536
+ The last positional argument can optionally accept an array of
537
+ values, by using the `..` operator:
538
+
539
+ ```js
540
+ yargs.command('download <url> [files..]', 'download several files')
541
+ .help()
542
+ .argv
543
+ ```
544
+
531
545
  ### Providing a Command Module
532
546
 
533
547
  For complicated commands you can pull the logic into a module. A module
534
548
  simply needs to export:
535
549
 
536
- * `exports.builder`: which describes the options that a command accepts.
550
+ * `exports.command`: string that executes this command when given on the command line, may contain positional args
551
+ * `exports.describe`: string used as the description for the command in help text, use `false` for a hidden command
552
+ * `exports.builder`: object declaring the options the command accepts, or a function accepting and returning a yargs instance
537
553
  * `exports.handler`: a function which will be passed the parsed argv.
538
554
 
539
555
  ```js
540
556
  // my-module.js
557
+ exports.command = 'get <source> [proxy]'
558
+
559
+ exports.describe = 'make a get HTTP request'
560
+
541
561
  exports.builder = {
542
562
  banana: {
543
563
  default: 'cool'
@@ -554,14 +574,22 @@ exports.handler = function (argv) {
554
574
 
555
575
  You then register the module like so:
556
576
 
577
+ ```js
578
+ yargs.command(require('my-module'))
579
+ .help()
580
+ .argv
581
+ ```
582
+
583
+ Or if the module does not export `command` and `describe` (or if you just want to override them):
584
+
557
585
  ```js
558
586
  yargs.command('get <source> [proxy]', 'make a get HTTP request', require('my-module'))
559
587
  .help()
560
588
  .argv
561
589
  ```
562
590
 
563
- .completion(cmd, [description], [fn]);
564
- -------------
591
+ .completion([cmd], [description], [fn]);
592
+ ----------------------------------------
565
593
 
566
594
  Enable bash-completion shortcuts for commands and options.
567
595
 
@@ -576,6 +604,9 @@ that generates bash completion scripts.
576
604
  shiver me timbers is pretty awesome, you can provide your own completion
577
605
  method.
578
606
 
607
+ If invoked without parameters, `.completion()` will make `completion` the command to output
608
+ the completion script.
609
+
579
610
  ```js
580
611
  var argv = require('yargs')
581
612
  .completion('completion', function(current, argv) {
@@ -619,13 +650,15 @@ var argv = require('yargs')
619
650
  .argv;
620
651
  ```
621
652
 
622
- <a name="config"></a>.config(key, [description], [parseFn])
653
+ <a name="config"></a>.config([key], [description], [parseFn])
623
654
  ------------
624
655
 
625
656
  Tells the parser that if the option specified by `key` is passed in, it
626
657
  should be interpreted as a path to a JSON config file. The file is loaded
627
658
  and parsed, and its properties are set as arguments.
628
659
 
660
+ If invoked without parameters, `.config()` will make `--config` the option to pass the JSON config file.
661
+
629
662
  An optional `description` can be provided to customize the config (`key`) option
630
663
  in the usage string.
631
664
 
@@ -729,6 +762,9 @@ Should yargs attempt to detect the os' locale? Defaults to `true`.
729
762
  Tell yargs to parse environment variables matching the given prefix and apply
730
763
  them to argv as though they were command line arguments.
731
764
 
765
+ Use the "__" separator in the environment variable to indicate nested options.
766
+ (e.g. prefix_nested__foo => nested.foo)
767
+
732
768
  If this method is called with no argument or with an empty string or with `true`,
733
769
  then all env vars will be applied to argv.
734
770
 
@@ -813,7 +849,19 @@ yargs have been validated.
813
849
 
814
850
  Method to execute when a failure occurs, rather than printing the failure message.
815
851
 
816
- `fn` is called with the failure message that would have been printed.
852
+ `fn` is called with the failure message that would have been printed and the
853
+ `Error` instance originally thrown, if any.
854
+
855
+ ```js
856
+ var argv = require('yargs')
857
+ .fail(function (msg, err) {
858
+ if (err) throw err // preserve stack
859
+ console.error('You broke it!')
860
+ console.error(msg)
861
+ process.exit(1)
862
+ })
863
+ .argv
864
+ ```
817
865
 
818
866
  <a name="global"></a>.global(globals)
819
867
  ------------
@@ -880,9 +928,10 @@ help output.
880
928
  Example:
881
929
 
882
930
  ```js
883
- var yargs = require("yargs")['--help']
884
- .usage("$0 -operand1 number -operand2 number -operation [add|subtract]");
931
+ var yargs = require("yargs")(['--help'])
932
+ .usage("$0 -operand1 number -operand2 number -operation [add|subtract]")
885
933
  .help()
934
+ .argv
886
935
  ```
887
936
 
888
937
  Later on, `argv` can be retrieved with `yargs.argv`.
@@ -953,10 +1002,12 @@ Locales currently supported:
953
1002
  * **es:** Spanish.
954
1003
  * **fr:** French.
955
1004
  * **id:** Indonesian.
1005
+ * **it:** Italian.
956
1006
  * **ja:** Japanese.
957
1007
  * **ko:** Korean.
958
1008
  * **nb:** Norwegian Bokmål.
959
1009
  * **pirate:** American Pirate.
1010
+ * **pl:** Polish.
960
1011
  * **pt:** Portuguese.
961
1012
  * **pt_BR:** Brazilian Portuguese.
962
1013
  * **tr:** Turkish.
@@ -1427,3 +1478,5 @@ This module is loosely inspired by Perl's
1427
1478
  [windows-image]: https://img.shields.io/appveyor/ci/bcoe/yargs/master.svg?label=Windows%20Tests
1428
1479
  [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
1429
1480
  [standard-url]: http://standardjs.com/
1481
+ [standard-version-image]: https://img.shields.io/badge/release-standard%20version-brightgreen.svg
1482
+ [standard-version-url]: https://github.com/conventional-changelog/standard-version
package/completion.sh.hbs CHANGED
@@ -10,10 +10,10 @@ _yargs_completions()
10
10
  local cur_word args type_list
11
11
 
12
12
  cur_word="${COMP_WORDS[COMP_CWORD]}"
13
- args=$(printf "%s " "${COMP_WORDS[@]}")
13
+ args=("${COMP_WORDS[@]}")
14
14
 
15
15
  # ask yargs to generate completions.
16
- type_list=`{{app_path}} --get-yargs-completions $args`
16
+ type_list=$({{app_path}} --get-yargs-completions "${args[@]}")
17
17
 
18
18
  COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )
19
19
 
package/index.js CHANGED
@@ -5,7 +5,7 @@ var yargs = require('./yargs')
5
5
 
6
6
  Argv(process.argv.slice(2))
7
7
 
8
- var exports = module.exports = Argv
8
+ module.exports = Argv
9
9
 
10
10
  function Argv (processArgs, cwd) {
11
11
  var argv = yargs(processArgs, cwd, require)
@@ -13,8 +13,6 @@ function Argv (processArgs, cwd) {
13
13
  return argv
14
14
  }
15
15
 
16
- exports.rebase = yargs.rebase
17
-
18
16
  /* Hack an instance of Argv with process.argv into Argv
19
17
  so people can do
20
18
  require('yargs')(['--beeble=1','-z','zizzle']).argv
package/lib/command.js CHANGED
@@ -45,15 +45,26 @@ module.exports = function (yargs, usage, validation) {
45
45
 
46
46
  function parseCommand (cmd) {
47
47
  var splitCommand = cmd.split(/\s/)
48
- var bregex = /[\][<>]/g
48
+ var bregex = /\.*[\][<>]/g
49
49
  var parsedCommand = {
50
50
  cmd: (splitCommand.shift()).replace(bregex, ''),
51
51
  demanded: [],
52
52
  optional: []
53
53
  }
54
- splitCommand.forEach(function (cmd) {
55
- if (/^\[/.test(cmd)) parsedCommand.optional.push(cmd.replace(bregex, ''))
56
- else parsedCommand.demanded.push(cmd.replace(bregex, ''))
54
+ splitCommand.forEach(function (cmd, i) {
55
+ var variadic = false
56
+ if (/\.+[\]>]/.test(cmd) && i === splitCommand.length - 1) variadic = true
57
+ if (/^\[/.test(cmd)) {
58
+ parsedCommand.optional.push({
59
+ cmd: cmd.replace(bregex, ''),
60
+ variadic: variadic
61
+ })
62
+ } else {
63
+ parsedCommand.demanded.push({
64
+ cmd: cmd.replace(bregex, ''),
65
+ variadic: variadic
66
+ })
67
+ }
57
68
  })
58
69
  return parsedCommand
59
70
  }
@@ -70,6 +81,9 @@ module.exports = function (yargs, usage, validation) {
70
81
  var argv = parsed.argv
71
82
  var commandHandler = handlers[command]
72
83
  var innerArgv = argv
84
+ var currentContext = yargs.getContext()
85
+ var parentCommands = currentContext.commands.slice()
86
+ currentContext.commands.push(command)
73
87
  if (commandHandler.builder && typeof commandHandler.builder === 'function') {
74
88
  // a function can be provided, which interacts which builds
75
89
  // up a yargs chain and returns it.
@@ -79,48 +93,53 @@ module.exports = function (yargs, usage, validation) {
79
93
  // original command string as usage() for consistent behavior with
80
94
  // options object below
81
95
  if (yargs.parsed === false && typeof yargs.getUsageInstance().getUsage() === 'undefined') {
82
- yargs.usage('$0 ' + commandHandler.original)
96
+ yargs.usage('$0 ' + (parentCommands.length ? parentCommands.join(' ') + ' ' : '') + commandHandler.original)
83
97
  }
84
98
  innerArgv = innerArgv ? innerArgv.argv : argv
85
99
  } else if (commandHandler.builder && typeof commandHandler.builder === 'object') {
86
100
  // as a short hand, an object can instead be provided, specifying
87
101
  // the options that a command takes.
88
102
  innerArgv = yargs.reset(parsed.aliases)
89
- innerArgv.usage('$0 ' + commandHandler.original)
103
+ innerArgv.usage('$0 ' + (parentCommands.length ? parentCommands.join(' ') + ' ' : '') + commandHandler.original)
90
104
  Object.keys(commandHandler.builder).forEach(function (key) {
91
105
  innerArgv.option(key, commandHandler.builder[key])
92
106
  })
93
107
  innerArgv = innerArgv.argv
94
108
  }
95
109
 
96
- populatePositional(commandHandler, innerArgv)
110
+ populatePositional(commandHandler, innerArgv, currentContext)
97
111
 
98
112
  if (commandHandler.handler) {
99
113
  commandHandler.handler(innerArgv)
100
114
  }
115
+ currentContext.commands.pop()
101
116
  return innerArgv
102
117
  }
103
118
 
104
- function populatePositional (commandHandler, argv) {
105
- var cmd = argv._.shift() // nuke the first argument (the current command)
119
+ function populatePositional (commandHandler, argv, context) {
120
+ argv._ = argv._.slice(context.commands.length) // nuke the current commands
106
121
  var demanded = commandHandler.demanded.slice(0)
107
122
  var optional = commandHandler.optional.slice(0)
108
123
 
109
124
  validation.positionalCount(demanded.length, argv._.length)
110
125
 
111
126
  while (demanded.length) {
112
- if (!argv._.length) break
113
127
  var demand = demanded.shift()
114
- argv[demand] = argv._.shift()
128
+ if (demand.variadic) argv[demand.cmd] = []
129
+ if (!argv._.length) break
130
+ if (demand.variadic) argv[demand.cmd] = argv._.splice(0)
131
+ else argv[demand.cmd] = argv._.shift()
115
132
  }
116
133
 
117
134
  while (optional.length) {
118
- if (!argv._.length) break
119
135
  var maybe = optional.shift()
120
- argv[maybe] = argv._.shift()
136
+ if (maybe.variadic) argv[maybe.cmd] = []
137
+ if (!argv._.length) break
138
+ if (maybe.variadic) argv[maybe.cmd] = argv._.splice(0)
139
+ else argv[maybe.cmd] = argv._.shift()
121
140
  }
122
141
 
123
- argv._.unshift(cmd)
142
+ argv._ = context.commands.concat(argv._)
124
143
  }
125
144
 
126
145
  self.reset = function () {
package/lib/completion.js CHANGED
@@ -14,6 +14,7 @@ module.exports = function (yargs, usage, command) {
14
14
  var current = process.argv[process.argv.length - 1]
15
15
  var previous = process.argv.slice(process.argv.indexOf('--' + self.completionKey) + 1)
16
16
  var argv = yargs.parse(previous)
17
+ var aliases = yargs.parsed.aliases
17
18
 
18
19
  // a custom completion function can be provided
19
20
  // to completion().
@@ -57,7 +58,14 @@ module.exports = function (yargs, usage, command) {
57
58
 
58
59
  if (current.match(/^-/)) {
59
60
  Object.keys(yargs.getOptions().key).forEach(function (key) {
60
- completions.push('--' + key)
61
+ // If the key and its aliases aren't in 'previous', add the key to 'completions'
62
+ var keyAndAliases = [key].concat(aliases[key] || [])
63
+ var notInPrevious = keyAndAliases.every(function (val) {
64
+ return previous.indexOf('--' + val) === -1
65
+ })
66
+ if (notInPrevious) {
67
+ completions.push('--' + key)
68
+ }
61
69
  })
62
70
  }
63
71
 
package/lib/usage.js CHANGED
@@ -320,8 +320,9 @@ module.exports = function (yargs, y18n) {
320
320
  }
321
321
 
322
322
  self.showHelp = function (level) {
323
- level = level || 'error'
324
- console[level](self.help())
323
+ if (!level) level = 'error'
324
+ var emit = typeof level === 'function' ? level : console[ level ]
325
+ emit(self.help())
325
326
  }
326
327
 
327
328
  self.functionDescription = function (fn) {
package/lib/validation.js CHANGED
@@ -109,6 +109,7 @@ module.exports = function (yargs, usage, y18n) {
109
109
  var demanded = yargs.getDemanded()
110
110
  var commandKeys = yargs.getCommandInstance().getCommands()
111
111
  var unknown = []
112
+ var currentContext = yargs.getContext()
112
113
 
113
114
  Object.keys(aliases).forEach(function (key) {
114
115
  aliases[key].forEach(function (alias) {
@@ -126,7 +127,7 @@ module.exports = function (yargs, usage, y18n) {
126
127
  })
127
128
 
128
129
  if (commandKeys.length > 0) {
129
- argv._.forEach(function (key) {
130
+ argv._.slice(currentContext.commands.length).forEach(function (key) {
130
131
  if (commandKeys.indexOf(key) === -1) {
131
132
  unknown.push(key)
132
133
  }
package/locales/en.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "boolean": "boolean",
6
6
  "count": "count",
7
7
  "string": "string",
8
+ "number": "number",
8
9
  "array": "array",
9
10
  "required": "required",
10
11
  "default:": "default:",
package/locales/it.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "boolean": "booleano",
6
6
  "count": "contatore",
7
7
  "string": "stringa",
8
+ "number": "numero",
8
9
  "array": "vettore",
9
10
  "required": "richiesto",
10
11
  "default:": "predefinito:",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "yargs",
3
- "version": "4.3.2",
4
- "description": "Light-weight option parsing with an argv hash. No optstrings attached.",
3
+ "version": "4.6.0",
4
+ "description": "yargs the modern, pirate-themed, successor to optimist.",
5
5
  "main": "./index.js",
6
6
  "files": [
7
7
  "index.js",
@@ -13,36 +13,38 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "camelcase": "^2.0.1",
16
- "cliui": "^3.0.3",
16
+ "cliui": "^3.2.0",
17
17
  "decamelize": "^1.1.1",
18
18
  "lodash.assign": "^4.0.3",
19
19
  "os-locale": "^1.4.0",
20
- "pkg-conf": "^1.1.1",
20
+ "pkg-conf": "^1.1.2",
21
21
  "read-pkg-up": "^1.0.1",
22
22
  "require-main-filename": "^1.0.1",
23
23
  "string-width": "^1.0.1",
24
24
  "window-size": "^0.2.0",
25
- "y18n": "^3.2.0",
26
- "yargs-parser": "^2.1.1"
25
+ "y18n": "^3.2.1",
26
+ "yargs-parser": "^2.4.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "chai": "^3.4.1",
30
- "chalk": "^1.1.1",
31
- "coveralls": "^2.11.4",
30
+ "chalk": "^1.1.3",
31
+ "coveralls": "^2.11.9",
32
32
  "cpr": "^1.0.0",
33
+ "cross-spawn-async": "^2.2.1",
33
34
  "es6-promise": "^3.0.2",
34
35
  "hashish": "0.0.4",
35
36
  "mocha": "^2.4.5",
36
- "nyc": "^6.0.0",
37
+ "nyc": "^6.1.1",
37
38
  "rimraf": "^2.5.0",
38
39
  "standard": "^6.0.5",
39
- "which": "^1.1.2",
40
- "win-spawn": "^2.0.0"
40
+ "standard-version": "^2.1.2",
41
+ "which": "^1.1.2"
41
42
  },
42
43
  "scripts": {
43
44
  "pretest": "standard",
44
45
  "test": "nyc --cache mocha --require ./test/before.js --timeout=4000 --check-leaks",
45
- "coverage": "nyc report --reporter=text-lcov | coveralls"
46
+ "coverage": "nyc report --reporter=text-lcov | coveralls",
47
+ "version": "standard-version"
46
48
  },
47
49
  "repository": {
48
50
  "type": "git",
@@ -67,4 +69,4 @@
67
69
  "engine": {
68
70
  "node": ">=0.10"
69
71
  }
70
- }
72
+ }
package/yargs.js CHANGED
@@ -35,9 +35,9 @@ function Yargs (processArgs, cwd, parentRequire) {
35
35
  .map(function (x, i) {
36
36
  // ignore the node bin, specify this in your
37
37
  // bin file with #!/usr/bin/env node
38
- if (i === 0 && /\b(node|iojs)$/.test(x)) return
38
+ if (i === 0 && /\b(node|iojs)(\.exe)?$/.test(x)) return
39
39
  var b = rebase(cwd, x)
40
- return x.match(/^\//) && b.length < x.length ? b : x
40
+ return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x
41
41
  })
42
42
  .join(' ').trim()
43
43
 
@@ -47,11 +47,19 @@ function Yargs (processArgs, cwd, parentRequire) {
47
47
  )
48
48
  }
49
49
 
50
+ // use context object to keep track of resets, subcommand execution, etc
51
+ // submodules should modify and check the state of context as necessary
52
+ var context = { resets: -1, commands: [] }
53
+ self.getContext = function () {
54
+ return context
55
+ }
56
+
50
57
  // puts yargs back into an initial state. any keys
51
58
  // that have been set to "global" will not be reset
52
59
  // by this action.
53
60
  var options
54
61
  self.resetOptions = self.reset = function (aliases) {
62
+ context.resets++
55
63
  aliases = aliases || {}
56
64
  options = options || {}
57
65
  // put yargs back into an initial state, this
@@ -171,6 +179,8 @@ function Yargs (processArgs, cwd, parentRequire) {
171
179
  parseFn = msg
172
180
  msg = null
173
181
  }
182
+
183
+ key = key || 'config'
174
184
  self.describe(key, msg || usage.deferY18nLookup('Path to JSON config file'))
175
185
  ;(Array.isArray(key) ? key : [key]).forEach(function (k) {
176
186
  options.config[k] = parseFn || true
@@ -234,6 +244,7 @@ function Yargs (processArgs, cwd, parentRequire) {
234
244
  max.forEach(function (key) {
235
245
  self.demand(key, msg)
236
246
  })
247
+ max = Infinity
237
248
  } else if (typeof max !== 'number') {
238
249
  msg = max
239
250
  max = Infinity