yargs 13.2.2 → 14.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 +70 -1
- package/README.md +14 -1
- package/index.js +9 -1
- package/lib/apply-extends.js +1 -1
- package/lib/command.js +14 -20
- package/lib/completion-templates.js +49 -0
- package/lib/completion.js +2 -5
- package/lib/usage.js +13 -12
- package/lib/validation.js +5 -4
- package/locales/de.json +1 -1
- package/locales/en.json +1 -1
- package/locales/fr.json +1 -1
- package/locales/it.json +1 -1
- package/locales/nl.json +16 -16
- package/package.json +7 -7
- package/yargs.js +25 -16
- package/completion.sh.hbs +0 -28
- package/completion.zsh.hbs +0 -17
- package/lib/decamelize.js +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
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
|
+
## [14.0.0](https://github.com/yargs/yargs/compare/v13.3.0...v14.0.0) (2019-07-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* we now only officially support yargs.$0 parameter and discourage direct access to yargs.parsed
|
|
11
|
+
* previously to this fix methods like `yargs.getOptions()` contained the state of the last command to execute.
|
|
12
|
+
* do not allow additional positionals in strict mode
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* calling parse multiple times now appropriately maintains state ([#1137](https://github.com/yargs/yargs/issues/1137)) ([#1369](https://github.com/yargs/yargs/issues/1369)) ([026b151](https://github.com/yargs/yargs/commit/026b151))
|
|
17
|
+
* prefer user supplied script name in usage ([#1383](https://github.com/yargs/yargs/issues/1383)) ([28c74b9](https://github.com/yargs/yargs/commit/28c74b9))
|
|
18
|
+
* **deps:** use decamelize from npm instead of vendored copy ([#1377](https://github.com/yargs/yargs/issues/1377)) ([015eeb9](https://github.com/yargs/yargs/commit/015eeb9))
|
|
19
|
+
* **examples:** fix usage-options.js to reflect current API ([#1375](https://github.com/yargs/yargs/issues/1375)) ([6e5b76b](https://github.com/yargs/yargs/commit/6e5b76b))
|
|
20
|
+
* do not allow additional positionals in strict mode ([35d777c](https://github.com/yargs/yargs/commit/35d777c))
|
|
21
|
+
* properties accessed on singleton now reflect current state of instance ([#1366](https://github.com/yargs/yargs/issues/1366)) ([409d35b](https://github.com/yargs/yargs/commit/409d35b))
|
|
22
|
+
* tolerate null prototype for config objects with `extends` ([#1376](https://github.com/yargs/yargs/issues/1376)) ([3d26d11](https://github.com/yargs/yargs/commit/3d26d11)), closes [#1372](https://github.com/yargs/yargs/issues/1372)
|
|
23
|
+
* yargs.parsed now populated before returning, when yargs.parse() called with no args (#1382) ([e3981fd](https://github.com/yargs/yargs/commit/e3981fd)), closes [#1382](https://github.com/yargs/yargs/issues/1382)
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* adds support for multiple epilog messages ([#1384](https://github.com/yargs/yargs/issues/1384)) ([07a5554](https://github.com/yargs/yargs/commit/07a5554))
|
|
28
|
+
* allow completionCommand to be set via showCompletionScript ([#1385](https://github.com/yargs/yargs/issues/1385)) ([5562853](https://github.com/yargs/yargs/commit/5562853))
|
|
29
|
+
|
|
30
|
+
## [13.3.0](https://www.github.com/yargs/yargs/compare/v13.2.4...v13.3.0) (2019-06-10)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* **deps:** yargs-parser update addressing several parsing bugs ([#1357](https://www.github.com/yargs/yargs/issues/1357)) ([e230d5b](https://www.github.com/yargs/yargs/commit/e230d5b))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* **i18n:** swap out os-locale dependency for simple inline implementation ([#1356](https://www.github.com/yargs/yargs/issues/1356)) ([4dfa19b](https://www.github.com/yargs/yargs/commit/4dfa19b))
|
|
41
|
+
* support defaultDescription for positional arguments ([812048c](https://www.github.com/yargs/yargs/commit/812048c))
|
|
42
|
+
|
|
43
|
+
### [13.2.4](https://github.com/yargs/yargs/compare/v13.2.3...v13.2.4) (2019-05-13)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
48
|
+
* **i18n:** rename unclear 'implication failed' to 'missing dependent arguments' ([#1317](https://github.com/yargs/yargs/issues/1317)) ([bf46813](https://github.com/yargs/yargs/commit/bf46813))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### [13.2.3](https://github.com/yargs/yargs/compare/v13.2.2...v13.2.3) (2019-05-05)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Bug Fixes
|
|
56
|
+
|
|
57
|
+
* **deps:** upgrade cliui for compatibility with latest chalk. ([#1330](https://github.com/yargs/yargs/issues/1330)) ([b20db65](https://github.com/yargs/yargs/commit/b20db65))
|
|
58
|
+
* address issues with dutch translation ([#1316](https://github.com/yargs/yargs/issues/1316)) ([0295132](https://github.com/yargs/yargs/commit/0295132))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Tests
|
|
62
|
+
|
|
63
|
+
* accept differently formatted output ([#1327](https://github.com/yargs/yargs/issues/1327)) ([c294d1b](https://github.com/yargs/yargs/commit/c294d1b))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
5
67
|
## [13.2.2](https://github.com/yargs/yargs/compare/v13.2.1...v13.2.2) (2019-03-06)
|
|
6
68
|
|
|
7
69
|
|
|
@@ -15,6 +77,13 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
15
77
|
* support options/sub-commands in zsh completion ([0a96394](https://github.com/yargs/yargs/commit/0a96394))
|
|
16
78
|
|
|
17
79
|
|
|
80
|
+
# [13.2.0](https://github.com/yargs/yargs/compare/v13.1.0...v13.2.0) (2019-02-15)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Features
|
|
84
|
+
|
|
85
|
+
* zsh auto completion ([#1292](https://github.com/yargs/yargs/issues/1292)) ([16c5d25](https://github.com/yargs/yargs/commit/16c5d25)), closes [#1156](https://github.com/yargs/yargs/issues/1156)
|
|
86
|
+
|
|
18
87
|
|
|
19
88
|
<a name="13.1.0"></a>
|
|
20
89
|
# [13.1.0](https://github.com/yargs/yargs/compare/v13.0.0...v13.1.0) (2019-02-12)
|
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<b >Yargs be a node.js library fer hearties tryin' ter parse optstrings</b>
|
|
7
7
|
</p>
|
|
8
|
+
|
|
8
9
|
<br>
|
|
9
10
|
|
|
10
11
|
[![Build Status][travis-image]][travis-url]
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
[![Slack][slack-image]][slack-url]
|
|
16
17
|
|
|
17
18
|
## Description :
|
|
18
|
-
Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.
|
|
19
|
+
Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.
|
|
19
20
|
|
|
20
21
|
It gives you:
|
|
21
22
|
|
|
@@ -86,6 +87,16 @@ require('yargs') // eslint-disable-line
|
|
|
86
87
|
|
|
87
88
|
Run the example above with `--help` to see the help for the application.
|
|
88
89
|
|
|
90
|
+
## TypeScript
|
|
91
|
+
|
|
92
|
+
yargs has type definitions at [@types/yargs][type-definitions].
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
npm i @types/yargs --save-dev
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
See usage examples in [docs](/docs/typescript.md)
|
|
99
|
+
|
|
89
100
|
## Community :
|
|
90
101
|
|
|
91
102
|
Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com).
|
|
@@ -102,6 +113,7 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc
|
|
|
102
113
|
* [Numbers](/docs/tricks.md#numbers)
|
|
103
114
|
* [Arrays](/docs/tricks.md#arrays)
|
|
104
115
|
* [Objects](/docs/tricks.md#objects)
|
|
116
|
+
* [Quotes](/docs/tricks.md#quotes)
|
|
105
117
|
* [Advanced Topics](/docs/advanced.md)
|
|
106
118
|
* [Composing Your App Using Commands](/docs/advanced.md#commands)
|
|
107
119
|
* [Building Configurable CLI Apps](/docs/advanced.md#configuration)
|
|
@@ -120,3 +132,4 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc
|
|
|
120
132
|
[conventional-commits-url]: https://conventionalcommits.org/
|
|
121
133
|
[slack-image]: http://devtoolscommunity.herokuapp.com/badge.svg
|
|
122
134
|
[slack-url]: http://devtoolscommunity.herokuapp.com
|
|
135
|
+
[type-definitions]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs
|
package/index.js
CHANGED
|
@@ -25,8 +25,16 @@ function singletonify (inst) {
|
|
|
25
25
|
Object.keys(inst).forEach((key) => {
|
|
26
26
|
if (key === 'argv') {
|
|
27
27
|
Argv.__defineGetter__(key, inst.__lookupGetter__(key))
|
|
28
|
+
} else if (typeof inst[key] === 'function') {
|
|
29
|
+
Argv[key] = inst[key].bind(inst)
|
|
28
30
|
} else {
|
|
29
|
-
Argv
|
|
31
|
+
Argv.__defineGetter__('$0', () => {
|
|
32
|
+
return inst.$0
|
|
33
|
+
})
|
|
34
|
+
Argv.__defineGetter__('parsed', () => {
|
|
35
|
+
console.warn('In future major releases of yargs, "parsed" will be a private field. Use the return value of ".parse()" or ".argv" instead')
|
|
36
|
+
return inst.parsed
|
|
37
|
+
})
|
|
30
38
|
}
|
|
31
39
|
})
|
|
32
40
|
}
|
package/lib/apply-extends.js
CHANGED
|
@@ -19,7 +19,7 @@ function getPathToDefaultConfig (cwd, pathToExtend) {
|
|
|
19
19
|
function applyExtends (config, cwd) {
|
|
20
20
|
let defaultConfig = {}
|
|
21
21
|
|
|
22
|
-
if (
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(config, 'extends')) {
|
|
23
23
|
if (typeof config.extends !== 'string') return defaultConfig
|
|
24
24
|
const isPath = /\.json|\..*rc$/.test(config.extends)
|
|
25
25
|
let pathToDefault = null
|
package/lib/command.js
CHANGED
|
@@ -186,24 +186,17 @@ module.exports = function command (yargs, usage, validation, globalMiddleware) {
|
|
|
186
186
|
// a function can be provided, which builds
|
|
187
187
|
// up a yargs chain and possibly returns it.
|
|
188
188
|
innerYargs = commandHandler.builder(yargs.reset(parsed.aliases))
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
// original command string as usage() for consistent behavior with
|
|
192
|
-
// options object below.
|
|
193
|
-
if (yargs.parsed === false) {
|
|
194
|
-
if (shouldUpdateUsage(yargs)) {
|
|
195
|
-
yargs.getUsageInstance().usage(
|
|
196
|
-
usageFromParentCommandsCommandHandler(parentCommands, commandHandler),
|
|
197
|
-
commandHandler.description
|
|
198
|
-
)
|
|
199
|
-
}
|
|
200
|
-
innerArgv = innerYargs ? innerYargs._parseArgs(null, null, true, commandIndex) : yargs._parseArgs(null, null, true, commandIndex)
|
|
201
|
-
} else {
|
|
202
|
-
innerArgv = yargs.parsed.argv
|
|
189
|
+
if (!innerYargs || (typeof innerYargs._parseArgs !== 'function')) {
|
|
190
|
+
innerYargs = yargs
|
|
203
191
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
192
|
+
if (shouldUpdateUsage(innerYargs)) {
|
|
193
|
+
innerYargs.getUsageInstance().usage(
|
|
194
|
+
usageFromParentCommandsCommandHandler(parentCommands, commandHandler),
|
|
195
|
+
commandHandler.description
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
innerArgv = innerYargs._parseArgs(null, null, true, commandIndex)
|
|
199
|
+
aliases = innerYargs.parsed.aliases
|
|
207
200
|
} else if (typeof commandHandler.builder === 'object') {
|
|
208
201
|
// as a short hand, an object can instead be provided, specifying
|
|
209
202
|
// the options that a command takes.
|
|
@@ -419,18 +412,19 @@ module.exports = function command (yargs, usage, validation, globalMiddleware) {
|
|
|
419
412
|
// the state of commands such that
|
|
420
413
|
// we can apply .parse() multiple times
|
|
421
414
|
// with the same yargs instance.
|
|
422
|
-
let
|
|
415
|
+
let frozens = []
|
|
423
416
|
self.freeze = () => {
|
|
424
|
-
frozen = {}
|
|
417
|
+
let frozen = {}
|
|
418
|
+
frozens.push(frozen)
|
|
425
419
|
frozen.handlers = handlers
|
|
426
420
|
frozen.aliasMap = aliasMap
|
|
427
421
|
frozen.defaultCommand = defaultCommand
|
|
428
422
|
}
|
|
429
423
|
self.unfreeze = () => {
|
|
424
|
+
let frozen = frozens.pop()
|
|
430
425
|
handlers = frozen.handlers
|
|
431
426
|
aliasMap = frozen.aliasMap
|
|
432
427
|
defaultCommand = frozen.defaultCommand
|
|
433
|
-
frozen = undefined
|
|
434
428
|
}
|
|
435
429
|
|
|
436
430
|
return self
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
exports.completionShTemplate =
|
|
2
|
+
`###-begin-{{app_name}}-completions-###
|
|
3
|
+
#
|
|
4
|
+
# yargs command completion script
|
|
5
|
+
#
|
|
6
|
+
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
|
7
|
+
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
|
8
|
+
#
|
|
9
|
+
_yargs_completions()
|
|
10
|
+
{
|
|
11
|
+
local cur_word args type_list
|
|
12
|
+
|
|
13
|
+
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
|
14
|
+
args=("\${COMP_WORDS[@]}")
|
|
15
|
+
|
|
16
|
+
# ask yargs to generate completions.
|
|
17
|
+
type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
|
|
18
|
+
|
|
19
|
+
COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
|
|
20
|
+
|
|
21
|
+
# if no match was found, fall back to filename completion
|
|
22
|
+
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
|
23
|
+
COMPREPLY=()
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
return 0
|
|
27
|
+
}
|
|
28
|
+
complete -o default -F _yargs_completions {{app_name}}
|
|
29
|
+
###-end-{{app_name}}-completions-###
|
|
30
|
+
`
|
|
31
|
+
|
|
32
|
+
exports.completionZshTemplate = `###-begin-{{app_name}}-completions-###
|
|
33
|
+
#
|
|
34
|
+
# yargs command completion script
|
|
35
|
+
#
|
|
36
|
+
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
|
37
|
+
# or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
|
|
38
|
+
#
|
|
39
|
+
_{{app_name}}_yargs_completions()
|
|
40
|
+
{
|
|
41
|
+
local reply
|
|
42
|
+
local si=$IFS
|
|
43
|
+
IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
|
|
44
|
+
IFS=$si
|
|
45
|
+
_describe 'values' reply
|
|
46
|
+
}
|
|
47
|
+
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
48
|
+
###-end-{{app_name}}-completions-###
|
|
49
|
+
`
|
package/lib/completion.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const fs = require('fs')
|
|
3
2
|
const path = require('path')
|
|
4
3
|
|
|
5
4
|
// add bash completions to your
|
|
@@ -92,10 +91,8 @@ module.exports = function completion (yargs, usage, command) {
|
|
|
92
91
|
|
|
93
92
|
// generate the completion script to add to your .bashrc.
|
|
94
93
|
self.generateCompletionScript = function generateCompletionScript ($0, cmd) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
'utf-8'
|
|
98
|
-
)
|
|
94
|
+
const templates = require('./completion-templates')
|
|
95
|
+
let script = zshShell ? templates.completionZshTemplate : templates.completionShTemplate
|
|
99
96
|
const name = path.basename($0)
|
|
100
97
|
|
|
101
98
|
// add ./to applications not yet installed as bin.
|
package/lib/usage.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
// this file handles outputting usage instructions,
|
|
3
3
|
// failures, etc. keeps logging in one place.
|
|
4
|
-
const decamelize = require('
|
|
4
|
+
const decamelize = require('decamelize')
|
|
5
5
|
const stringWidth = require('string-width')
|
|
6
6
|
const objFilter = require('./obj-filter')
|
|
7
7
|
const path = require('path')
|
|
@@ -122,9 +122,9 @@ module.exports = function usage (yargs, y18n) {
|
|
|
122
122
|
}
|
|
123
123
|
self.getDescriptions = () => descriptions
|
|
124
124
|
|
|
125
|
-
let
|
|
125
|
+
let epilogs = []
|
|
126
126
|
self.epilog = (msg) => {
|
|
127
|
-
|
|
127
|
+
epilogs.push(msg)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
let wrapSet = false
|
|
@@ -151,7 +151,7 @@ module.exports = function usage (yargs, y18n) {
|
|
|
151
151
|
normalizeAliases()
|
|
152
152
|
|
|
153
153
|
// handle old demanded API
|
|
154
|
-
const base$0 = path.basename(yargs.$0)
|
|
154
|
+
const base$0 = yargs.customScriptName ? yargs.$0 : path.basename(yargs.$0)
|
|
155
155
|
const demandedOptions = yargs.getDemandedOptions()
|
|
156
156
|
const demandedCommands = yargs.getDemandedCommands()
|
|
157
157
|
const groups = yargs.getGroups()
|
|
@@ -345,8 +345,8 @@ module.exports = function usage (yargs, y18n) {
|
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
// the usage string.
|
|
348
|
-
if (
|
|
349
|
-
const e = epilog.replace(/\$0/g, base$0)
|
|
348
|
+
if (epilogs.length > 0) {
|
|
349
|
+
const e = epilogs.map(epilog => epilog.replace(/\$0/g, base$0)).join('\n')
|
|
350
350
|
ui.div(`${e}\n`)
|
|
351
351
|
}
|
|
352
352
|
|
|
@@ -505,35 +505,36 @@ module.exports = function usage (yargs, y18n) {
|
|
|
505
505
|
failureOutput = false
|
|
506
506
|
usages = []
|
|
507
507
|
usageDisabled = false
|
|
508
|
-
|
|
508
|
+
epilogs = []
|
|
509
509
|
examples = []
|
|
510
510
|
commands = []
|
|
511
511
|
descriptions = objFilter(descriptions, (k, v) => !localLookup[k])
|
|
512
512
|
return self
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
let
|
|
515
|
+
let frozens = []
|
|
516
516
|
self.freeze = function freeze () {
|
|
517
|
-
frozen = {}
|
|
517
|
+
let frozen = {}
|
|
518
|
+
frozens.push(frozen)
|
|
518
519
|
frozen.failMessage = failMessage
|
|
519
520
|
frozen.failureOutput = failureOutput
|
|
520
521
|
frozen.usages = usages
|
|
521
522
|
frozen.usageDisabled = usageDisabled
|
|
522
|
-
frozen.
|
|
523
|
+
frozen.epilogs = epilogs
|
|
523
524
|
frozen.examples = examples
|
|
524
525
|
frozen.commands = commands
|
|
525
526
|
frozen.descriptions = descriptions
|
|
526
527
|
}
|
|
527
528
|
self.unfreeze = function unfreeze () {
|
|
529
|
+
let frozen = frozens.pop()
|
|
528
530
|
failMessage = frozen.failMessage
|
|
529
531
|
failureOutput = frozen.failureOutput
|
|
530
532
|
usages = frozen.usages
|
|
531
533
|
usageDisabled = frozen.usageDisabled
|
|
532
|
-
|
|
534
|
+
epilogs = frozen.epilogs
|
|
533
535
|
examples = frozen.examples
|
|
534
536
|
commands = frozen.commands
|
|
535
537
|
descriptions = frozen.descriptions
|
|
536
|
-
frozen = undefined
|
|
537
538
|
}
|
|
538
539
|
|
|
539
540
|
return self
|
package/lib/validation.js
CHANGED
|
@@ -102,7 +102,7 @@ module.exports = function validation (yargs, usage, y18n) {
|
|
|
102
102
|
}
|
|
103
103
|
})
|
|
104
104
|
|
|
105
|
-
if (commandKeys.length > 0) {
|
|
105
|
+
if ((currentContext.commands.length > 0) || (commandKeys.length > 0)) {
|
|
106
106
|
argv._.slice(currentContext.commands.length).forEach((key) => {
|
|
107
107
|
if (commandKeys.indexOf(key) === -1) {
|
|
108
108
|
unknown.push(key)
|
|
@@ -323,18 +323,19 @@ module.exports = function validation (yargs, usage, y18n) {
|
|
|
323
323
|
return self
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
-
let
|
|
326
|
+
let frozens = []
|
|
327
327
|
self.freeze = function freeze () {
|
|
328
|
-
frozen = {}
|
|
328
|
+
let frozen = {}
|
|
329
|
+
frozens.push(frozen)
|
|
329
330
|
frozen.implied = implied
|
|
330
331
|
frozen.checks = checks
|
|
331
332
|
frozen.conflicting = conflicting
|
|
332
333
|
}
|
|
333
334
|
self.unfreeze = function unfreeze () {
|
|
335
|
+
let frozen = frozens.pop()
|
|
334
336
|
implied = frozen.implied
|
|
335
337
|
checks = frozen.checks
|
|
336
338
|
conflicting = frozen.conflicting
|
|
337
|
-
frozen = undefined
|
|
338
339
|
}
|
|
339
340
|
|
|
340
341
|
return self
|
package/locales/de.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"Invalid values:": "Unzulässige Werte:",
|
|
30
30
|
"Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gegeben: %s, Möglichkeiten: %s",
|
|
31
31
|
"Argument check failed: %s": "Argumente-Check fehlgeschlagen: %s",
|
|
32
|
-
"Implications failed:": "
|
|
32
|
+
"Implications failed:": "Fehlende abhängige Argumente:",
|
|
33
33
|
"Not enough arguments following: %s": "Nicht genügend Argumente nach: %s",
|
|
34
34
|
"Invalid JSON config file: %s": "Fehlerhafte JSON-Config Datei: %s",
|
|
35
35
|
"Path to JSON config file": "Pfad zur JSON-Config Datei",
|
package/locales/en.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"Invalid values:": "Invalid values:",
|
|
30
30
|
"Argument: %s, Given: %s, Choices: %s": "Argument: %s, Given: %s, Choices: %s",
|
|
31
31
|
"Argument check failed: %s": "Argument check failed: %s",
|
|
32
|
-
"Implications failed:": "
|
|
32
|
+
"Implications failed:": "Missing dependent arguments:",
|
|
33
33
|
"Not enough arguments following: %s": "Not enough arguments following: %s",
|
|
34
34
|
"Invalid JSON config file: %s": "Invalid JSON config file: %s",
|
|
35
35
|
"Path to JSON config file": "Path to JSON config file",
|
package/locales/fr.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"Invalid values:": "Valeurs invalides:",
|
|
29
29
|
"Argument: %s, Given: %s, Choices: %s": "Argument: %s, Donné: %s, Choix: %s",
|
|
30
30
|
"Argument check failed: %s": "Echec de la vérification de l'argument: %s",
|
|
31
|
-
"Implications failed:": "
|
|
31
|
+
"Implications failed:": "Arguments dépendants manquants:",
|
|
32
32
|
"Not enough arguments following: %s": "Pas assez d'arguments suivant: %s",
|
|
33
33
|
"Invalid JSON config file: %s": "Fichier de configuration JSON invalide: %s",
|
|
34
34
|
"Path to JSON config file": "Chemin du fichier de configuration JSON",
|
package/locales/it.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"Invalid values:": "Valori non validi:",
|
|
30
30
|
"Argument: %s, Given: %s, Choices: %s": "Argomento: %s, Richiesto: %s, Scelte: %s",
|
|
31
31
|
"Argument check failed: %s": "Controllo dell'argomento fallito: %s",
|
|
32
|
-
"Implications failed:": "Argomenti
|
|
32
|
+
"Implications failed:": "Argomenti dipendenti mancanti:",
|
|
33
33
|
"Not enough arguments following: %s": "Argomenti insufficienti dopo: %s",
|
|
34
34
|
"Invalid JSON config file: %s": "File di configurazione JSON non valido: %s",
|
|
35
35
|
"Path to JSON config file": "Percorso del file di configurazione JSON",
|
package/locales/nl.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
"Commands:": "
|
|
2
|
+
"Commands:": "Commando's:",
|
|
3
3
|
"Options:": "Opties:",
|
|
4
4
|
"Examples:": "Voorbeelden:",
|
|
5
|
-
"boolean": "
|
|
5
|
+
"boolean": "booleaans",
|
|
6
6
|
"count": "aantal",
|
|
7
|
-
"string": "
|
|
8
|
-
"number": "
|
|
7
|
+
"string": "string",
|
|
8
|
+
"number": "getal",
|
|
9
9
|
"array": "lijst",
|
|
10
10
|
"required": "verplicht",
|
|
11
11
|
"default:": "standaard:",
|
|
12
12
|
"choices:": "keuzes:",
|
|
13
13
|
"aliases:": "aliassen:",
|
|
14
14
|
"generated-value": "gegenereerde waarde",
|
|
15
|
-
"Not enough non-option arguments: got %s, need at least %s": "Niet genoeg
|
|
16
|
-
"Too many non-option arguments: got %s, maximum of %s": "Te veel
|
|
15
|
+
"Not enough non-option arguments: got %s, need at least %s": "Niet genoeg niet-optie-argumenten: %s gekregen, minstens %s nodig",
|
|
16
|
+
"Too many non-option arguments: got %s, maximum of %s": "Te veel niet-optie-argumenten: %s gekregen, maximum is %s",
|
|
17
17
|
"Missing argument value: %s": {
|
|
18
|
-
"one": "
|
|
19
|
-
"other": "
|
|
18
|
+
"one": "Missende argumentwaarde: %s",
|
|
19
|
+
"other": "Missende argumentwaarden: %s"
|
|
20
20
|
},
|
|
21
21
|
"Missing required argument: %s": {
|
|
22
|
-
"one": "Missend
|
|
22
|
+
"one": "Missend verplicht argument: %s",
|
|
23
23
|
"other": "Missende verplichte argumenten: %s"
|
|
24
24
|
},
|
|
25
25
|
"Unknown argument: %s": {
|
|
26
26
|
"one": "Onbekend argument: %s",
|
|
27
27
|
"other": "Onbekende argumenten: %s"
|
|
28
28
|
},
|
|
29
|
-
"Invalid values:": "Ongeldige
|
|
29
|
+
"Invalid values:": "Ongeldige waarden:",
|
|
30
30
|
"Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gegeven: %s, Keuzes: %s",
|
|
31
|
-
"Argument check failed: %s": "
|
|
32
|
-
"Implications failed:": "
|
|
31
|
+
"Argument check failed: %s": "Argumentcontrole mislukt: %s",
|
|
32
|
+
"Implications failed:": "Ontbrekende afhankelijke argumenten:",
|
|
33
33
|
"Not enough arguments following: %s": "Niet genoeg argumenten na: %s",
|
|
34
|
-
"Invalid JSON config file: %s": "Ongeldig JSON
|
|
35
|
-
"Path to JSON config file": "Pad naar JSON
|
|
34
|
+
"Invalid JSON config file: %s": "Ongeldig JSON-config-bestand: %s",
|
|
35
|
+
"Path to JSON config file": "Pad naar JSON-config-bestand",
|
|
36
36
|
"Show help": "Toon help",
|
|
37
|
-
"Show version number": "Toon
|
|
37
|
+
"Show version number": "Toon versienummer",
|
|
38
38
|
"Did you mean %s?": "Bedoelde u misschien %s?",
|
|
39
|
-
"Arguments %s and %s are mutually exclusive": "Argumenten %s en %s
|
|
39
|
+
"Arguments %s and %s are mutually exclusive": "Argumenten %s en %s kunnen niet tegelijk gebruikt worden",
|
|
40
40
|
"Positionals:": "Positie-afhankelijke argumenten",
|
|
41
41
|
"command": "commando"
|
|
42
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "yargs the modern, pirate-themed, successor to optimist.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"contributors": [
|
|
@@ -19,31 +19,31 @@
|
|
|
19
19
|
"LICENSE"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"cliui": "^
|
|
22
|
+
"cliui": "^5.0.0",
|
|
23
|
+
"decamelize": "^1.2.0",
|
|
23
24
|
"find-up": "^3.0.0",
|
|
24
25
|
"get-caller-file": "^2.0.1",
|
|
25
|
-
"os-locale": "^3.1.0",
|
|
26
26
|
"require-directory": "^2.1.1",
|
|
27
27
|
"require-main-filename": "^2.0.0",
|
|
28
28
|
"set-blocking": "^2.0.0",
|
|
29
29
|
"string-width": "^3.0.0",
|
|
30
30
|
"which-module": "^2.0.0",
|
|
31
31
|
"y18n": "^4.0.0",
|
|
32
|
-
"yargs-parser": "^13.
|
|
32
|
+
"yargs-parser": "^13.1.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"chai": "^4.2.0",
|
|
36
36
|
"chalk": "^2.4.2",
|
|
37
|
-
"coveralls": "^3.0.
|
|
37
|
+
"coveralls": "^3.0.3",
|
|
38
38
|
"cpr": "^3.0.1",
|
|
39
39
|
"cross-spawn": "^6.0.4",
|
|
40
40
|
"es6-promise": "^4.2.5",
|
|
41
41
|
"hashish": "0.0.4",
|
|
42
42
|
"mocha": "^5.2.0",
|
|
43
|
-
"nyc": "^
|
|
43
|
+
"nyc": "^14.1.0",
|
|
44
44
|
"rimraf": "^2.6.3",
|
|
45
45
|
"standard": "^12.0.1",
|
|
46
|
-
"standard-version": "^
|
|
46
|
+
"standard-version": "^7.0.0",
|
|
47
47
|
"which": "^1.3.1",
|
|
48
48
|
"yargs-test-extends": "^1.0.1"
|
|
49
49
|
},
|
package/yargs.js
CHANGED
|
@@ -37,7 +37,8 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
37
37
|
|
|
38
38
|
if (!cwd) cwd = process.cwd()
|
|
39
39
|
|
|
40
|
-
self.scriptName = function
|
|
40
|
+
self.scriptName = function (scriptName) {
|
|
41
|
+
self.customScriptName = true
|
|
41
42
|
self.$0 = scriptName
|
|
42
43
|
return self
|
|
43
44
|
}
|
|
@@ -144,9 +145,10 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
144
145
|
self.resetOptions()
|
|
145
146
|
|
|
146
147
|
// temporary hack: allow "freezing" of reset-able state for parse(msg, cb)
|
|
147
|
-
let
|
|
148
|
+
let frozens = []
|
|
148
149
|
function freeze () {
|
|
149
|
-
frozen = {}
|
|
150
|
+
let frozen = {}
|
|
151
|
+
frozens.push(frozen)
|
|
150
152
|
frozen.options = options
|
|
151
153
|
frozen.configObjects = options.configObjects.slice(0)
|
|
152
154
|
frozen.exitProcess = exitProcess
|
|
@@ -160,8 +162,11 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
160
162
|
frozen.exitError = exitError
|
|
161
163
|
frozen.hasOutput = hasOutput
|
|
162
164
|
frozen.parsed = self.parsed
|
|
165
|
+
frozen.parseFn = parseFn
|
|
166
|
+
frozen.parseContext = parseContext
|
|
163
167
|
}
|
|
164
168
|
function unfreeze () {
|
|
169
|
+
let frozen = frozens.pop()
|
|
165
170
|
options = frozen.options
|
|
166
171
|
options.configObjects = frozen.configObjects
|
|
167
172
|
exitProcess = frozen.exitProcess
|
|
@@ -175,9 +180,8 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
175
180
|
command.unfreeze()
|
|
176
181
|
strict = frozen.strict
|
|
177
182
|
completionCommand = frozen.completionCommand
|
|
178
|
-
parseFn =
|
|
179
|
-
parseContext =
|
|
180
|
-
frozen = undefined
|
|
183
|
+
parseFn = frozen.parseFn
|
|
184
|
+
parseContext = frozen.parseContext
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
self.boolean = function (keys) {
|
|
@@ -538,8 +542,12 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
538
542
|
let parseContext = null
|
|
539
543
|
self.parse = function parse (args, shortCircuit, _parseFn) {
|
|
540
544
|
argsert('[string|array] [function|boolean|object] [function]', [args, shortCircuit, _parseFn], arguments.length)
|
|
545
|
+
freeze()
|
|
541
546
|
if (typeof args === 'undefined') {
|
|
542
|
-
|
|
547
|
+
const parsed = self._parseArgs(processArgs)
|
|
548
|
+
unfreeze()
|
|
549
|
+
// TODO: remove this compatibility hack when we release yargs@15.x:
|
|
550
|
+
return (this.parsed = parsed)
|
|
543
551
|
}
|
|
544
552
|
|
|
545
553
|
// a context object can optionally be provided, this allows
|
|
@@ -560,7 +568,6 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
560
568
|
// skipping validation, etc.
|
|
561
569
|
if (!shortCircuit) processArgs = args
|
|
562
570
|
|
|
563
|
-
freeze()
|
|
564
571
|
if (parseFn) exitProcess = false
|
|
565
572
|
|
|
566
573
|
const parsed = self._parseArgs(args, shortCircuit)
|
|
@@ -694,8 +701,8 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
694
701
|
}
|
|
695
702
|
|
|
696
703
|
// .positional() only supports a subset of the configuration
|
|
697
|
-
// options
|
|
698
|
-
const supportedOpts = ['default', 'implies', 'normalize',
|
|
704
|
+
// options available to .option().
|
|
705
|
+
const supportedOpts = ['default', 'defaultDescription', 'implies', 'normalize',
|
|
699
706
|
'choices', 'conflicts', 'coerce', 'type', 'describe',
|
|
700
707
|
'desc', 'description', 'alias']
|
|
701
708
|
opts = objFilter(opts, (k, v) => {
|
|
@@ -901,7 +908,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
901
908
|
}
|
|
902
909
|
|
|
903
910
|
// register the completion command.
|
|
904
|
-
completionCommand = cmd || 'completion'
|
|
911
|
+
completionCommand = cmd || completionCommand || 'completion'
|
|
905
912
|
if (!desc && desc !== false) {
|
|
906
913
|
desc = 'generate completion script'
|
|
907
914
|
}
|
|
@@ -913,9 +920,10 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
913
920
|
return self
|
|
914
921
|
}
|
|
915
922
|
|
|
916
|
-
self.showCompletionScript = function ($0) {
|
|
917
|
-
argsert('[string]', [$0], arguments.length)
|
|
923
|
+
self.showCompletionScript = function ($0, cmd) {
|
|
924
|
+
argsert('[string] [string]', [$0, cmd], arguments.length)
|
|
918
925
|
$0 = $0 || self.$0
|
|
926
|
+
completionCommand = cmd || completionCommand || 'completion'
|
|
919
927
|
_logger.log(completion.generateCompletionScript($0, completionCommand))
|
|
920
928
|
return self
|
|
921
929
|
}
|
|
@@ -1023,7 +1031,7 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
1023
1031
|
// Deprecated
|
|
1024
1032
|
let pkgConfig = pkgUp()['yargs']
|
|
1025
1033
|
if (pkgConfig) {
|
|
1026
|
-
console.warn('Configuring yargs through package.json is deprecated and will be removed in
|
|
1034
|
+
console.warn('Configuring yargs through package.json is deprecated and will be removed in a future major release, please use the JS API instead.')
|
|
1027
1035
|
options.configuration = Object.assign({}, pkgConfig, options.configuration)
|
|
1028
1036
|
}
|
|
1029
1037
|
|
|
@@ -1181,8 +1189,9 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
1181
1189
|
if (!detectLocale) return
|
|
1182
1190
|
|
|
1183
1191
|
try {
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1192
|
+
const { env } = process
|
|
1193
|
+
const locale = env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE || 'en_US'
|
|
1194
|
+
self.locale(locale.replace(/[.:].*/, ''))
|
|
1186
1195
|
} catch (err) {
|
|
1187
1196
|
// if we explode looking up locale just noop
|
|
1188
1197
|
// we'll keep using the default language 'en'.
|
package/completion.sh.hbs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
###-begin-{{app_name}}-completions-###
|
|
2
|
-
#
|
|
3
|
-
# yargs command completion script
|
|
4
|
-
#
|
|
5
|
-
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
|
6
|
-
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
|
7
|
-
#
|
|
8
|
-
_yargs_completions()
|
|
9
|
-
{
|
|
10
|
-
local cur_word args type_list
|
|
11
|
-
|
|
12
|
-
cur_word="${COMP_WORDS[COMP_CWORD]}"
|
|
13
|
-
args=("${COMP_WORDS[@]}")
|
|
14
|
-
|
|
15
|
-
# ask yargs to generate completions.
|
|
16
|
-
type_list=$({{app_path}} --get-yargs-completions "${args[@]}")
|
|
17
|
-
|
|
18
|
-
COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )
|
|
19
|
-
|
|
20
|
-
# if no match was found, fall back to filename completion
|
|
21
|
-
if [ ${#COMPREPLY[@]} -eq 0 ]; then
|
|
22
|
-
COMPREPLY=()
|
|
23
|
-
fi
|
|
24
|
-
|
|
25
|
-
return 0
|
|
26
|
-
}
|
|
27
|
-
complete -o default -F _yargs_completions {{app_name}}
|
|
28
|
-
###-end-{{app_name}}-completions-###
|
package/completion.zsh.hbs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
###-begin-{{app_name}}-completions-###
|
|
2
|
-
#
|
|
3
|
-
# yargs command completion script
|
|
4
|
-
#
|
|
5
|
-
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
|
6
|
-
# or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
|
|
7
|
-
#
|
|
8
|
-
_{{app_name}}_yargs_completions()
|
|
9
|
-
{
|
|
10
|
-
local reply
|
|
11
|
-
local si=$IFS
|
|
12
|
-
IFS=$'\n' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "${words[@]}"))
|
|
13
|
-
IFS=$si
|
|
14
|
-
_describe 'values' reply
|
|
15
|
-
}
|
|
16
|
-
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
17
|
-
###-end-{{app_name}}-completions-###
|
package/lib/decamelize.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
5
|
-
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
8
|
-
the Software without restriction, including without limitation the rights to
|
|
9
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
*/
|
|
23
|
-
'use strict'
|
|
24
|
-
|
|
25
|
-
module.exports = (text, separator) => {
|
|
26
|
-
separator = typeof separator === 'undefined' ? '_' : separator
|
|
27
|
-
|
|
28
|
-
return text
|
|
29
|
-
.replace(/([a-z\d])([A-Z])/g, `$1${separator}$2`)
|
|
30
|
-
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, `$1${separator}$2`)
|
|
31
|
-
.toLowerCase()
|
|
32
|
-
}
|