dashdash
Advanced tools
Comparing version 1.12.0 to 1.12.1
@@ -789,2 +789,7 @@ /** | ||
* <http://github.com/trentm/node-cmdln> Bash completion for details. | ||
* @param opts.includeHidden {Boolean} Optional. Default false. By default | ||
* hidden options and subcmds are "excluded". Here excluded means they | ||
* won't be offered as a completion, but if used, their argument type | ||
* will be completed. "Hidden" options and subcmds are ones with the | ||
* `hidden: true` attribute to exclude them from default help output. | ||
*/ | ||
@@ -795,4 +800,7 @@ function bashCompletionSpecFromOptions(args) { | ||
assert.optionalString(args.context, 'args.context'); | ||
assert.optionalBool(args.includeHidden, 'args.includeHidden'); | ||
var context = args.context || ''; | ||
var includeHidden = (args.includeHidden === undefined | ||
? false : args.includeHidden); | ||
@@ -816,6 +824,12 @@ var spec = []; | ||
if (optName.length === 1) { | ||
shortopts.push('-' + optName); | ||
if (includeHidden || !o.hidden) { | ||
shortopts.push('-' + optName); | ||
} | ||
// Include even hidden options in `optargs` so that bash | ||
// completion of its arg still works. | ||
optargs.push('-' + optName + '=' + completionType); | ||
} else { | ||
longopts.push('--' + optName); | ||
if (includeHidden || !o.hidden) { | ||
longopts.push('--' + optName); | ||
} | ||
optargs.push('--' + optName + '=' + completionType); | ||
@@ -826,6 +840,8 @@ } | ||
optNames.forEach(function (optName) { | ||
if (optName.length === 1) { | ||
shortopts.push('-' + optName); | ||
} else { | ||
longopts.push('--' + optName); | ||
if (includeHidden || !o.hidden) { | ||
if (optName.length === 1) { | ||
shortopts.push('-' + optName); | ||
} else { | ||
longopts.push('--' + optName); | ||
} | ||
} | ||
@@ -832,0 +848,0 @@ }); |
{ | ||
"name": "dashdash", | ||
"description": "A light, featureful and explicit option parsing library.", | ||
"version": "1.12.0", | ||
"version": "1.12.1", | ||
"author": "Trent Mick <trentm@gmail.com> (http://trentm.com)", | ||
@@ -6,0 +6,0 @@ "keywords": ["option", "parser", "parsing", "cli", "command", "args", |
@@ -275,3 +275,9 @@ A light, featureful and explicit option parsing library for node.js. | ||
<!-- | ||
TODO: document specExtra | ||
TODO: document includeHidden | ||
TODO: document custom types, `function complete_FOO` guide, completionType | ||
--> | ||
# Parser config | ||
@@ -324,8 +330,9 @@ | ||
Example using all fields: | ||
Example using all fields (required fields are noted): | ||
```javascript | ||
{ | ||
names: ['file', 'f'], // Required (or `name`). | ||
names: ['file', 'f'], // Required (one of `names` or `name`). | ||
type: 'string', // Required. | ||
completionType: 'filename', | ||
env: 'MYTOOL_FILE', | ||
@@ -366,2 +373,16 @@ help: 'Config file to load before running "mytool"', | ||
- `completionType` (String). Optional. This is used for [Bash | ||
completion](#bash-completion) for an option argument. If not specified, | ||
then the value of `type` is used. Any string may be specified, but only the | ||
following values have meaning: | ||
- `none`: Provide no completions. | ||
- `file`: Bash's default completion (i.e. `complete -o default`), which | ||
includes filenames. | ||
- *Any string FOO for which a `function complete_FOO` Bash function is | ||
defined.* This is for custom completions for a given tool. Typically | ||
these custom functions are provided in the `specExtra` argument to | ||
`dashdash.bashCompletionFromOptions()`. See | ||
["examples/ddcompletion.js"](examples/ddcompletion.js) for an example. | ||
- `env` (String or Array of String). Optional. An environment variable name | ||
@@ -396,3 +417,4 @@ (or names) that can be used as a fallback for this option. For example, | ||
- `hidden` (Boolean). Optional, default false. If true, help output will not | ||
include this option. | ||
include this option. See also the `includeHidden` option to | ||
`bashCompletionFromOptions()` for [Bash completion](#bash-completion). | ||
@@ -483,3 +505,4 @@ | ||
arrayFlatten: false, // optional | ||
default: ... // optional | ||
default: ..., // optional | ||
completionType: ... // optional | ||
}); | ||
@@ -519,5 +542,5 @@ | ||
See the `addOptionType` block comment in "lib/dashdash.js" for more details. | ||
Please let me know [on twitter](https://twitter.com/trentmick) | ||
or [with an issue](https://github.com/trentm/node-dashdash/issues/new) if you | ||
write a generally useful one. | ||
Please let me know [with an | ||
issue](https://github.com/trentm/node-dashdash/issues/new) if you write a | ||
generally useful one. | ||
@@ -524,0 +547,0 @@ |
Sorry, the diff of this file is not supported yet
64239
896
576