yargs 10.1.2 → 11.0.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 +20 -0
- package/lib/validation.js +0 -34
- package/package.json +2 -2
- package/yargs.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
+
<a name="11.0.0"></a>
|
|
6
|
+
# [11.0.0](https://github.com/yargs/yargs/compare/v10.1.2...v11.0.0) (2018-01-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Set implicit nargs=1 when type=number requiresArg=true ([#1050](https://github.com/yargs/yargs/issues/1050)) ([2b56812](https://github.com/yargs/yargs/commit/2b56812))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* requiresArg is now simply an alias for nargs(1) ([#1054](https://github.com/yargs/yargs/issues/1054)) ([a3ddacc](https://github.com/yargs/yargs/commit/a3ddacc))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* requiresArg now has significantly different error output, matching nargs.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
5
25
|
<a name="10.1.2"></a>
|
|
6
26
|
## [10.1.2](https://github.com/yargs/yargs/compare/v10.1.1...v10.1.2) (2018-01-17)
|
|
7
27
|
|
package/lib/validation.js
CHANGED
|
@@ -54,40 +54,6 @@ module.exports = function validation (yargs, usage, y18n) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
// make sure that any args that require an
|
|
58
|
-
// value (--foo=bar), have a value.
|
|
59
|
-
self.missingArgumentValue = function missingArgumentValue (argv) {
|
|
60
|
-
const defaultValues = [true, false, '', undefined]
|
|
61
|
-
const options = yargs.getOptions()
|
|
62
|
-
if (options.requiresArg.length > 0) {
|
|
63
|
-
const missingRequiredArgs = []
|
|
64
|
-
|
|
65
|
-
options.requiresArg.forEach((key) => {
|
|
66
|
-
// if the argument is not set in argv no need to check
|
|
67
|
-
// whether a right-hand-side has been provided.
|
|
68
|
-
if (!argv.hasOwnProperty(key)) return
|
|
69
|
-
|
|
70
|
-
const value = argv[key]
|
|
71
|
-
// if a value is explicitly requested,
|
|
72
|
-
// flag argument as missing if it does not
|
|
73
|
-
// look like foo=bar was entered.
|
|
74
|
-
if (~defaultValues.indexOf(value) ||
|
|
75
|
-
(Array.isArray(value) && !value.length)) {
|
|
76
|
-
missingRequiredArgs.push(key)
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
if (missingRequiredArgs.length > 0) {
|
|
81
|
-
usage.fail(__n(
|
|
82
|
-
'Missing argument value: %s',
|
|
83
|
-
'Missing argument values: %s',
|
|
84
|
-
missingRequiredArgs.length,
|
|
85
|
-
missingRequiredArgs.join(', ')
|
|
86
|
-
))
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
57
|
// make sure all the required arguments are present.
|
|
92
58
|
self.requiredArguments = function requiredArguments (argv) {
|
|
93
59
|
const demandedOptions = yargs.getDemandedOptions()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "yargs the modern, pirate-themed, successor to optimist.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"string-width": "^2.0.0",
|
|
24
24
|
"which-module": "^2.0.0",
|
|
25
25
|
"y18n": "^3.2.1",
|
|
26
|
-
"yargs-parser": "^
|
|
26
|
+
"yargs-parser": "^9.0.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"chai": "^4.1.2",
|
package/yargs.js
CHANGED
|
@@ -92,7 +92,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
92
92
|
groups = {}
|
|
93
93
|
|
|
94
94
|
const arrayOptions = [
|
|
95
|
-
'array', 'boolean', 'string', '
|
|
95
|
+
'array', 'boolean', 'string', 'skipValidation',
|
|
96
96
|
'count', 'normalize', 'number'
|
|
97
97
|
]
|
|
98
98
|
|
|
@@ -204,7 +204,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
204
204
|
|
|
205
205
|
self.requiresArg = function (keys) {
|
|
206
206
|
argsert('<array|string>', [keys], arguments.length)
|
|
207
|
-
|
|
207
|
+
populateParserHintObject(self.nargs, false, 'narg', keys, 1)
|
|
208
208
|
return self
|
|
209
209
|
}
|
|
210
210
|
|
|
@@ -964,6 +964,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
964
964
|
|
|
965
965
|
options.__ = y18n.__
|
|
966
966
|
options.configuration = pkgUp()['yargs'] || {}
|
|
967
|
+
|
|
967
968
|
const parsed = Parser.detailed(args, options)
|
|
968
969
|
let argv = parsed.argv
|
|
969
970
|
if (parseContext) argv = Object.assign({}, argv, parseContext)
|
|
@@ -1106,7 +1107,6 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
1106
1107
|
self._runValidation = function runValidation (argv, aliases, positionalMap, parseErrors) {
|
|
1107
1108
|
if (parseErrors) throw new YError(parseErrors.message)
|
|
1108
1109
|
validation.nonOptionCount(argv)
|
|
1109
|
-
validation.missingArgumentValue(argv)
|
|
1110
1110
|
validation.requiredArguments(argv)
|
|
1111
1111
|
if (strict) validation.unknownArguments(argv, aliases, positionalMap)
|
|
1112
1112
|
validation.customChecks(argv, aliases)
|