Comparing version 3.5.2 to 3.5.3
# node-cmdln Changelog | ||
## 3.5.3 | ||
- Bash completion: Add `completionArgtypes`: | ||
CLI.prototype.do_<subcmd>.completionArgtypes = <array>;` | ||
to be able to define custom completion types for positional args. | ||
Also update to dashdash 1.12.2 for bash completion improvements. Of note, | ||
this changes so that `mytool <TAB>` does *not* offer options as completions, | ||
`mytool -<TAB>` does. See [dashdash's | ||
changelog](https://github.com/trentm/node-dashdash/blob/master/CHANGES.md#1122). | ||
See "examples/conan.js" for an example: | ||
$ alias conan="node examples/conan.js" | ||
$ conan completion > /usr/local/etc/bash_completion.d/conan | ||
$ source /usr/local/etc/bash_completion.d/conan | ||
$ conan crush --weapon | ||
bow-and-array mattock spear sword | ||
$ conan crush --weapon spear | ||
King-Osric Subotai Thulsa-Doom _mbsetupuser trentm | ||
## 3.5.2 | ||
@@ -4,0 +27,0 @@ |
@@ -554,2 +554,8 @@ /* | ||
} else { | ||
if (handler.completionArgtypes) { | ||
assert.arrayOfString(handler.completionArgtypes, | ||
'do_' + name + '.completionArgtypes'); | ||
spec.push(format('local cmd%s_argtypes="%s"', | ||
context_, handler.completionArgtypes.join(' '))); | ||
} | ||
spec.push(dashdash.bashCompletionSpecFromOptions({ | ||
@@ -556,0 +562,0 @@ options: handler.options || [], |
{ | ||
"name": "cmdln", | ||
"version": "3.5.2", | ||
"version": "3.5.3", | ||
"description": "helper lib for creating CLI tools with subcommands; think `git`, `svn`, `zfs`", | ||
@@ -19,3 +19,3 @@ "author": "Trent Mick (http://trentm.com)", | ||
"verror": "^1.6.0", | ||
"dashdash": "^1.12.1" | ||
"dashdash": "^1.12.2" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
@@ -149,5 +149,11 @@ `node-cmdln` is a node.js helper lib for creating CLI tools with subcommands | ||
$ source conan.completion | ||
$ conan <TAB> | ||
--help --version -v completion hear see | ||
--verbose -h -x crush help smash | ||
crush hear help pulverize see smash | ||
$ conan -<TAB> | ||
--help --verbose --version -h -v -x | ||
$ conan crush --weapon <TAB> # custom 'weapon' completion type | ||
bow-and-array mattock spear sword | ||
$ conan crush --weapon spear <TAB> # custom 'enemy' completion type | ||
King-Osric Subotai Thulsa-Doom _mbsetupuser trentm | ||
@@ -237,2 +243,11 @@ See the `do_completion` subcommand on "examples/conan.js" for a complete example | ||
- `CLI.prototype.do_<subcmd>.completionArgtypes = <array>;` Set to an array | ||
of strings to define the [Bash completion](#bash-completion) type for the | ||
corresponding positional arg. For example, the following: | ||
MyCLI.prototype.do_foo.completionTypes = ['fruit', 'file']; | ||
would mean that `mycli foo <TAB>` would complete "fruit" (using a | ||
`complete_fruit` bash function, typically provided via the `specExtra` | ||
arg to `<cli>.bashCompletion()`) and the second and subsequent positional | ||
args -- `mycli foo banana <TAB>` -- would use filename completion. | ||
- `CLI.prototype.init(opts, args, cb)` Hook run after option processing | ||
@@ -239,0 +254,0 @@ (`this.opts` is set), but before the subcommand handler is run. |
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
67660
980
335
Updateddashdash@^1.12.2