Comparing version 3.12.0 to 3.13.0
## Change Log | ||
### v3.13.0 (2015/06/24 04:12 +00:00) | ||
- [#187](https://github.com/bcoe/yargs/pull/187) completion now behaves differently | ||
if it is being run in the context of a command (@tschaub) | ||
- [#186](https://github.com/bcoe/yargs/pull/186) if no matches are found for a completion | ||
default to filename completion (@tschaub) | ||
### v3.12.0 (2015/06/19 03:23 +00:00) | ||
@@ -4,0 +11,0 @@ - [#183](https://github.com/bcoe/yargs/pull/183) don't complete commands if they've already been completed (@tschaub) |
27
index.js
@@ -69,3 +69,2 @@ var assert = require('assert') | ||
versionOpt = null | ||
completionOpt = null | ||
commandHandlers = {} | ||
@@ -356,3 +355,2 @@ self.parsed = false | ||
var completionOpt = null | ||
var completionCommand = null | ||
@@ -370,3 +368,2 @@ self.completion = function (cmd, desc, fn) { | ||
completionCommand = cmd || 'completion' | ||
completionOpt = completion.completionKey | ||
self.command(completionCommand, desc || 'generate bash completion script') | ||
@@ -426,15 +423,7 @@ | ||
if (completionCommand && | ||
(process.argv.join(' ')).indexOf(completionOpt) !== -1 && | ||
!argv[completionOpt]) { | ||
(process.argv.join(' ')).indexOf(completion.completionKey) !== -1 && | ||
!argv[completion.completionKey]) { | ||
return argv | ||
} | ||
// generate a completion script for adding to ~/.bashrc. | ||
if (completionCommand && ~argv._.indexOf(completionCommand) && !argv[completionOpt]) { | ||
self.showCompletionScript() | ||
if (exitProcess) { | ||
process.exit(0) | ||
} | ||
} | ||
// if there's a handler associated with a | ||
@@ -450,5 +439,13 @@ // command defer processing to it. | ||
// generate a completion script for adding to ~/.bashrc. | ||
if (completionCommand && ~argv._.indexOf(completionCommand) && !argv[completion.completionKey]) { | ||
self.showCompletionScript() | ||
if (exitProcess) { | ||
process.exit(0) | ||
} | ||
} | ||
// we must run completions first, a user might | ||
// want to complete the --help or --version option. | ||
if (completionOpt in argv) { | ||
if (completion.completionKey in argv) { | ||
// we allow for asynchronous completions, | ||
@@ -484,3 +481,3 @@ // e.g., loading in a list of commands from an API. | ||
// bother with validation. | ||
if (!argv[completionOpt]) { | ||
if (!argv[completion.completionKey]) { | ||
validation.nonOptionCount(argv) | ||
@@ -487,0 +484,0 @@ validation.missingArgumentValue(argv) |
@@ -32,2 +32,9 @@ var fs = require('fs') | ||
var handlers = yargs.getCommandHandlers() | ||
for (var i = 0, ii = previous.length; i < ii; ++i) { | ||
if (handlers[previous[i]]) { | ||
return handlers[previous[i]](yargs.reset()) | ||
} | ||
} | ||
if (!current.match(/^-/)) { | ||
@@ -34,0 +41,0 @@ usage.getCommands().forEach(function (command) { |
{ | ||
"name": "yargs", | ||
"version": "3.12.0", | ||
"version": "3.13.0", | ||
"description": "Light-weight option parsing with an argv hash. No optstrings attached.", | ||
@@ -24,3 +24,3 @@ "main": "./index.js", | ||
"nyc": "^2.2.1", | ||
"standard": "^4.2.1" | ||
"standard": "^4.3.2" | ||
}, | ||
@@ -80,2 +80,6 @@ "scripts": { | ||
"url": "https://github.com/linclark" | ||
}, | ||
{ | ||
"name": "Tim Schaub", | ||
"url": "https://github.com/tschaub" | ||
} | ||
@@ -82,0 +86,0 @@ ], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105349
1320