yargs 3.26.0 → 3.27.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 +7 -0
- package/README.md +1 -0
- package/index.js +19 -12
- package/lib/usage.js +10 -5
- package/locales/zh.json +36 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### v3.26.0 (2015/09/25 2:14 +00:00)
|
|
4
|
+
|
|
5
|
+
- [#263](https://github.com/bcoe/yargs/pull/263) document count() and option() object keys (@nexdrew)
|
|
6
|
+
- [#259](https://github.com/bcoe/yargs/pull/259) remove util in readme (@38elements)
|
|
7
|
+
- [#258](https://github.com/bcoe/yargs/pull/258) node v4 builds, update deps (@nexdrew)
|
|
8
|
+
- [#257](https://github.com/bcoe/yargs/pull/257) fix spelling errors (@dkoleary88)
|
|
9
|
+
|
|
3
10
|
### v3.25.0 (2015/09/13 7:38 -07:00)
|
|
4
11
|
|
|
5
12
|
- [#254](https://github.com/bcoe/yargs/pull/254) adds Japanese translation (@oti)
|
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -511,13 +511,16 @@ function Argv (processArgs, cwd) {
|
|
|
511
511
|
return
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
+
var helpOrVersion = false
|
|
514
515
|
Object.keys(argv).forEach(function (key) {
|
|
515
516
|
if (key === helpOpt && argv[key]) {
|
|
517
|
+
helpOrVersion = true
|
|
516
518
|
self.showHelp('log')
|
|
517
519
|
if (exitProcess) {
|
|
518
520
|
process.exit(0)
|
|
519
521
|
}
|
|
520
522
|
} else if (key === versionOpt && argv[key]) {
|
|
523
|
+
helpOrVersion = true
|
|
521
524
|
usage.showVersion()
|
|
522
525
|
if (exitProcess) {
|
|
523
526
|
process.exit(0)
|
|
@@ -525,18 +528,22 @@ function Argv (processArgs, cwd) {
|
|
|
525
528
|
}
|
|
526
529
|
})
|
|
527
530
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
validation.
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
531
|
+
// If the help or version options where used and exitProcess is false,
|
|
532
|
+
// we won't run validations
|
|
533
|
+
if (!helpOrVersion) {
|
|
534
|
+
if (parsed.error) throw parsed.error
|
|
535
|
+
|
|
536
|
+
// if we're executed via bash completion, don't
|
|
537
|
+
// bother with validation.
|
|
538
|
+
if (!argv[completion.completionKey]) {
|
|
539
|
+
validation.nonOptionCount(argv)
|
|
540
|
+
validation.missingArgumentValue(argv)
|
|
541
|
+
validation.requiredArguments(argv)
|
|
542
|
+
if (strict) validation.unknownArguments(argv, aliases)
|
|
543
|
+
validation.customChecks(argv, aliases)
|
|
544
|
+
validation.limitedChoices(argv)
|
|
545
|
+
validation.implications(argv)
|
|
546
|
+
}
|
|
540
547
|
}
|
|
541
548
|
|
|
542
549
|
setPlaceholderKeys(argv)
|
package/lib/usage.js
CHANGED
|
@@ -28,17 +28,22 @@ module.exports = function (yargs, y18n) {
|
|
|
28
28
|
return self
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
var failureOutput = false
|
|
31
32
|
self.fail = function (msg) {
|
|
32
33
|
if (fails.length) {
|
|
33
34
|
fails.forEach(function (f) {
|
|
34
35
|
f(msg)
|
|
35
36
|
})
|
|
36
37
|
} else {
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
console.error(
|
|
38
|
+
// don't output failure message more than once
|
|
39
|
+
if (!failureOutput) {
|
|
40
|
+
failureOutput = true
|
|
41
|
+
if (showHelpOnFail) yargs.showHelp('error')
|
|
42
|
+
if (msg) console.error(msg)
|
|
43
|
+
if (failMessage) {
|
|
44
|
+
if (msg) console.error('')
|
|
45
|
+
console.error(failMessage)
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
if (yargs.getExitProcess()) {
|
|
44
49
|
process.exit(1)
|
package/locales/zh.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Commands:": "命令:",
|
|
3
|
+
"Options:": "选项:",
|
|
4
|
+
"Examples:": "示例:",
|
|
5
|
+
"boolean": "boolean",
|
|
6
|
+
"count": "count",
|
|
7
|
+
"string": "string",
|
|
8
|
+
"array": "array",
|
|
9
|
+
"required": "required",
|
|
10
|
+
"default:": "默认值:",
|
|
11
|
+
"choices:": "可选值:",
|
|
12
|
+
"generated-value": "生成的值",
|
|
13
|
+
"Not enough non-option arguments: got %s, need at least %s": "缺少 non-option 参数:传入了 %s 个, 至少需要 %s 个",
|
|
14
|
+
"Too many non-option arguments: got %s, maximum of %s": "non-option 参数过多:传入了 %s 个, 最大允许 %s 个",
|
|
15
|
+
"Missing argument value: %s": {
|
|
16
|
+
"one": "没有给此选项指定值:%s",
|
|
17
|
+
"other": "没有给这些选项指定值:%s"
|
|
18
|
+
},
|
|
19
|
+
"Missing required argument: %s": {
|
|
20
|
+
"one": "缺少必须的选项:%s",
|
|
21
|
+
"other": "缺少这些必须的选项:%s"
|
|
22
|
+
},
|
|
23
|
+
"Unknown argument: %s": {
|
|
24
|
+
"one": "无法识别的选项:%s",
|
|
25
|
+
"other": "无法识别这些选项:%s"
|
|
26
|
+
},
|
|
27
|
+
"Invalid values:": "无效的选项值:",
|
|
28
|
+
"Argument: %s, Given: %s, Choices: %s": "选项名称: %s, 传入的值: %s, 可选的值:%s",
|
|
29
|
+
"Argument check failed: %s": "选项值验证失败:%s",
|
|
30
|
+
"Implications failed:": "缺少依赖的选项:",
|
|
31
|
+
"Not enough arguments following: %s": "没有提供足够的值给此选项:%s",
|
|
32
|
+
"Invalid JSON config file: %s": "无效的 JSON 配置文件:%s",
|
|
33
|
+
"Path to JSON config file": "JSON 配置文件的路径",
|
|
34
|
+
"Show help": "显示帮助信息",
|
|
35
|
+
"Show version number": "显示版本号"
|
|
36
|
+
}
|