yargs 13.1.0 → 13.2.4

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,7 +1,52 @@
1
- # Change Log
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
+ ### [13.2.4](https://github.com/yargs/yargs/compare/v13.2.3...v13.2.4) (2019-05-13)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **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))
11
+
12
+
13
+
14
+ ### [13.2.3](https://github.com/yargs/yargs/compare/v13.2.2...v13.2.3) (2019-05-05)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **deps:** upgrade cliui for compatibility with latest chalk. ([#1330](https://github.com/yargs/yargs/issues/1330)) ([b20db65](https://github.com/yargs/yargs/commit/b20db65))
20
+ * address issues with dutch translation ([#1316](https://github.com/yargs/yargs/issues/1316)) ([0295132](https://github.com/yargs/yargs/commit/0295132))
21
+
22
+
23
+ ### Tests
24
+
25
+ * accept differently formatted output ([#1327](https://github.com/yargs/yargs/issues/1327)) ([c294d1b](https://github.com/yargs/yargs/commit/c294d1b))
26
+
27
+
28
+
29
+ ## [13.2.2](https://github.com/yargs/yargs/compare/v13.2.1...v13.2.2) (2019-03-06)
30
+
31
+
32
+
33
+ ## [13.2.1](https://github.com/yargs/yargs/compare/v13.2.0...v13.2.1) (2019-02-18)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * add zsh script to files array ([3180224](https://github.com/yargs/yargs/commit/3180224))
39
+ * support options/sub-commands in zsh completion ([0a96394](https://github.com/yargs/yargs/commit/0a96394))
40
+
41
+
42
+ # [13.2.0](https://github.com/yargs/yargs/compare/v13.1.0...v13.2.0) (2019-02-15)
43
+
44
+
45
+ ### Features
46
+
47
+ * 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)
48
+
49
+
5
50
  <a name="13.1.0"></a>
6
51
  # [13.1.0](https://github.com/yargs/yargs/compare/v13.0.0...v13.1.0) (2019-02-12)
7
52
 
@@ -26,7 +71,8 @@ All notable changes to this project will be documented in this file. See [standa
26
71
 
27
72
  ### Chores
28
73
 
29
- * drop Node 6 from testing matrix ([#1287](https://github.com/yargs/yargs/issues/1287)) ([ef16792](https://github.com/yargs/yargs/commit/ef16792))
74
+ * ~drop Node 6 from testing matrix ([#1287](https://github.com/yargs/yargs/issues/1287)) ([ef16792](https://github.com/yargs/yargs/commit/ef16792))~
75
+ * _opting to not drop Node 6 support until April, [see](https://github.com/nodejs/Release)._
30
76
  * update dependencies ([#1284](https://github.com/yargs/yargs/issues/1284)) ([f25de4f](https://github.com/yargs/yargs/commit/f25de4f))
31
77
 
32
78
 
package/README.md CHANGED
@@ -31,12 +31,12 @@ It gives you:
31
31
 
32
32
  Stable version:
33
33
  ```bash
34
- npm i yargs --save
34
+ npm i yargs
35
35
  ```
36
36
 
37
37
  Bleeding edge version with the most recent features:
38
38
  ```bash
39
- npm i yargs@next --save
39
+ npm i yargs@next
40
40
  ```
41
41
 
42
42
  ## Usage :
package/lib/argsert.js CHANGED
@@ -12,7 +12,7 @@ function argsert (expected, callerArguments, length) {
12
12
  // preface the argument description with "cmd", so
13
13
  // that we can run it through yargs' command parser.
14
14
  let position = 0
15
- let parsed = {demanded: [], optional: []}
15
+ let parsed = { demanded: [], optional: [] }
16
16
  if (typeof expected === 'object') {
17
17
  length = callerArguments
18
18
  callerArguments = expected
package/lib/command.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const inspect = require('util').inspect
4
4
  const isPromise = require('./is-promise')
5
- const {applyMiddleware, commandMiddlewareFactory} = require('./middleware')
5
+ const { applyMiddleware, commandMiddlewareFactory } = require('./middleware')
6
6
  const path = require('path')
7
7
  const Parser = require('yargs-parser')
8
8
 
@@ -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
@@ -9,6 +8,7 @@ module.exports = function completion (yargs, usage, command) {
9
8
  completionKey: 'get-yargs-completions'
10
9
  }
11
10
 
11
+ const zshShell = process.env.SHELL && process.env.SHELL.indexOf('zsh') !== -1
12
12
  // get a list of completion commands.
13
13
  // 'args' is the array of strings from the line to be completed
14
14
  self.getCompletion = function getCompletion (args, done) {
@@ -16,6 +16,7 @@ module.exports = function completion (yargs, usage, command) {
16
16
  const current = args.length ? args[args.length - 1] : ''
17
17
  const argv = yargs.parse(args, true)
18
18
  const aliases = yargs.parsed.aliases
19
+ const parentCommands = yargs.getContext().commands
19
20
 
20
21
  // a custom completion function can be provided
21
22
  // to completion().
@@ -54,22 +55,33 @@ module.exports = function completion (yargs, usage, command) {
54
55
  }
55
56
  }
56
57
 
57
- if (!current.match(/^-/)) {
58
+ if (!current.match(/^-/) && parentCommands[parentCommands.length - 1] !== current) {
58
59
  usage.getCommands().forEach((usageCommand) => {
59
60
  const commandName = command.parseCommand(usageCommand[0]).cmd
60
61
  if (args.indexOf(commandName) === -1) {
61
- completions.push(commandName)
62
+ if (!zshShell) {
63
+ completions.push(commandName)
64
+ } else {
65
+ const desc = usageCommand[1] || ''
66
+ completions.push(commandName.replace(/:/g, '\\:') + ':' + desc)
67
+ }
62
68
  }
63
69
  })
64
70
  }
65
71
 
66
- if (current.match(/^-/)) {
72
+ if (current.match(/^-/) || (current === '' && completions.length === 0)) {
73
+ const descs = usage.getDescriptions()
67
74
  Object.keys(yargs.getOptions().key).forEach((key) => {
68
75
  // If the key and its aliases aren't in 'args', add the key to 'completions'
69
76
  const keyAndAliases = [key].concat(aliases[key] || [])
70
77
  const notInArgs = keyAndAliases.every(val => args.indexOf(`--${val}`) === -1)
71
78
  if (notInArgs) {
72
- completions.push(`--${key}`)
79
+ if (!zshShell) {
80
+ completions.push(`--${key}`)
81
+ } else {
82
+ const desc = descs[key] || ''
83
+ completions.push(`--${key.replace(/:/g, '\\:')}:${desc.replace('__yargsString__:', '')}`)
84
+ }
73
85
  }
74
86
  })
75
87
  }
@@ -79,10 +91,8 @@ module.exports = function completion (yargs, usage, command) {
79
91
 
80
92
  // generate the completion script to add to your .bashrc.
81
93
  self.generateCompletionScript = function generateCompletionScript ($0, cmd) {
82
- let script = fs.readFileSync(
83
- path.resolve(__dirname, '../completion.sh.hbs'),
84
- 'utf-8'
85
- )
94
+ const templates = require('./completion-templates')
95
+ let script = zshShell ? templates.completionZshTemplate : templates.completionShTemplate
86
96
  const name = path.basename($0)
87
97
 
88
98
  // add ./to applications not yet installed as bin.
package/lib/usage.js CHANGED
@@ -181,7 +181,7 @@ module.exports = function usage (yargs, y18n) {
181
181
  usages.forEach((usage) => {
182
182
  ui.div(`${usage[0].replace(/\$0/g, base$0)}`)
183
183
  if (usage[1]) {
184
- ui.div({text: `${usage[1]}`, padding: [1, 0, 0, 0]})
184
+ ui.div({ text: `${usage[1]}`, padding: [1, 0, 0, 0] })
185
185
  }
186
186
  })
187
187
  ui.div()
@@ -217,7 +217,7 @@ module.exports = function usage (yargs, y18n) {
217
217
  padding: [0, 2, 0, 2],
218
218
  width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4
219
219
  },
220
- {text: command[1]}
220
+ { text: command[1] }
221
221
  )
222
222
  const hints = []
223
223
  if (command[2]) hints.push(`[${__('default:').slice(0, -1)}]`) // TODO hacking around i18n here
@@ -225,7 +225,7 @@ module.exports = function usage (yargs, y18n) {
225
225
  hints.push(`[${__('aliases:')} ${command[3].join(', ')}]`)
226
226
  }
227
227
  if (hints.length) {
228
- ui.div({text: hints.join(' '), padding: [0, 0, 0, 2], align: 'right'})
228
+ ui.div({ text: hints.join(' '), padding: [0, 0, 0, 2], align: 'right' })
229
229
  } else {
230
230
  ui.div()
231
231
  }
@@ -301,11 +301,11 @@ module.exports = function usage (yargs, y18n) {
301
301
  ].filter(Boolean).join(' ')
302
302
 
303
303
  ui.span(
304
- {text: kswitch, padding: [0, 2, 0, 2], width: maxWidth(switches, theWrap) + 4},
304
+ { text: kswitch, padding: [0, 2, 0, 2], width: maxWidth(switches, theWrap) + 4 },
305
305
  desc
306
306
  )
307
307
 
308
- if (extra) ui.div({text: extra, padding: [0, 0, 0, 2], align: 'right'})
308
+ if (extra) ui.div({ text: extra, padding: [0, 0, 0, 2], align: 'right' })
309
309
  else ui.div()
310
310
  })
311
311
 
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:": "Implikationen fehlgeschlagen:",
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:": "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:": "Implications échouées:",
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 impliciti non soddisfatti:",
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:": "Opdrachten:",
2
+ "Commands:": "Commando's:",
3
3
  "Options:": "Opties:",
4
4
  "Examples:": "Voorbeelden:",
5
- "boolean": "boolean",
5
+ "boolean": "booleaans",
6
6
  "count": "aantal",
7
- "string": "text",
8
- "number": "nummer",
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 non-optie argumenten. Gekregen: %s, minstens nodig: %s",
16
- "Too many non-option arguments: got %s, maximum of %s": "Te veel non-optie argumenten. Gekregen: %s, maximum: %s",
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": "Missing argument value: %s",
19
- "other": "Missing argument values: %s"
18
+ "one": "Missende argumentwaarde: %s",
19
+ "other": "Missende argumentwaarden: %s"
20
20
  },
21
21
  "Missing required argument: %s": {
22
- "one": "Missend verplichte argument: %s",
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 waardes:",
29
+ "Invalid values:": "Ongeldige waarden:",
30
30
  "Argument: %s, Given: %s, Choices: %s": "Argument: %s, Gegeven: %s, Keuzes: %s",
31
- "Argument check failed: %s": "Argument check mislukt: %s",
32
- "Implications failed:": "Implicaties mislukt:",
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 configuratiebestand: %s",
35
- "Path to JSON config file": "Pad naar JSON configuratiebestand",
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 versie nummer",
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 zijn onderling uitsluitend",
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": "13.1.0",
3
+ "version": "13.2.4",
4
4
  "description": "yargs the modern, pirate-themed, successor to optimist.",
5
5
  "main": "./index.js",
6
6
  "contributors": [
@@ -15,10 +15,11 @@
15
15
  "lib",
16
16
  "locales",
17
17
  "completion.sh.hbs",
18
+ "completion.zsh.hbs",
18
19
  "LICENSE"
19
20
  ],
20
21
  "dependencies": {
21
- "cliui": "^4.0.0",
22
+ "cliui": "^5.0.0",
22
23
  "find-up": "^3.0.0",
23
24
  "get-caller-file": "^2.0.1",
24
25
  "os-locale": "^3.1.0",
@@ -28,21 +29,21 @@
28
29
  "string-width": "^3.0.0",
29
30
  "which-module": "^2.0.0",
30
31
  "y18n": "^4.0.0",
31
- "yargs-parser": "^13.0.0"
32
+ "yargs-parser": "^13.1.0"
32
33
  },
33
34
  "devDependencies": {
34
35
  "chai": "^4.2.0",
35
36
  "chalk": "^2.4.2",
36
- "coveralls": "^3.0.2",
37
+ "coveralls": "^3.0.3",
37
38
  "cpr": "^3.0.1",
38
39
  "cross-spawn": "^6.0.4",
39
40
  "es6-promise": "^4.2.5",
40
41
  "hashish": "0.0.4",
41
42
  "mocha": "^5.2.0",
42
- "nyc": "^13.2.0",
43
+ "nyc": "^14.1.0",
43
44
  "rimraf": "^2.6.3",
44
- "standard": "^11.0.1",
45
- "standard-version": "^4.4.0",
45
+ "standard": "^12.0.1",
46
+ "standard-version": "^6.0.1",
46
47
  "which": "^1.3.1",
47
48
  "yargs-test-extends": "^1.0.1"
48
49
  },
package/yargs.js CHANGED
@@ -11,7 +11,7 @@ const Y18n = require('y18n')
11
11
  const objFilter = require('./lib/obj-filter')
12
12
  const setBlocking = require('set-blocking')
13
13
  const applyExtends = require('./lib/apply-extends')
14
- const {globalMiddlewareFactory} = require('./lib/middleware')
14
+ const { globalMiddlewareFactory } = require('./lib/middleware')
15
15
  const YError = require('./lib/yerror')
16
16
 
17
17
  exports = module.exports = Yargs
@@ -903,7 +903,7 @@ function Yargs (processArgs, cwd, parentRequire) {
903
903
  // register the completion command.
904
904
  completionCommand = cmd || 'completion'
905
905
  if (!desc && desc !== false) {
906
- desc = 'generate bash completion script'
906
+ desc = 'generate completion script'
907
907
  }
908
908
  self.command(completionCommand, desc)
909
909
 
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-###