Comparing version 1.13.1 to 1.14.0
@@ -1002,2 +1002,34 @@ /** | ||
/** | ||
* Return a synopsis string for the given option spec. | ||
* | ||
* Examples: | ||
* > synopsisFromOpt({names: ['help', 'h'], type: 'bool'}); | ||
* '[ --help | -h ]' | ||
* > synopsisFromOpt({name: 'file', type: 'string', helpArg: 'FILE'}); | ||
* '[ --file=FILE ]' | ||
*/ | ||
function synopsisFromOpt(o) { | ||
assert.object(o, 'o'); | ||
if (o.hasOwnProperty('group')) { | ||
return null; | ||
} | ||
var names = o.names || [o.name]; | ||
// `type` here could be undefined if, for example, the command has a | ||
// dashdash option spec with a bogus 'type'. | ||
var type = getOptionType(o.type); | ||
var helpArg = o.helpArg || (type && type.helpArg) || 'ARG'; | ||
var parts = []; | ||
names.forEach(function (name) { | ||
var part = (name.length === 1 ? '-' : '--') + name; | ||
if (type && type.takesArg) { | ||
part += (name.length === 1 ? ' ' + helpArg : '=' + helpArg); | ||
} | ||
parts.push(part); | ||
}); | ||
return ('[ ' + parts.join(' | ') + ' ]'); | ||
}; | ||
module.exports = { | ||
@@ -1009,2 +1041,3 @@ createParser: createParser, | ||
getOptionType: getOptionType, | ||
synopsisFromOpt: synopsisFromOpt, | ||
@@ -1011,0 +1044,0 @@ // Bash completion-related exports |
{ | ||
"name": "dashdash", | ||
"description": "A light, featureful and explicit option parsing library.", | ||
"version": "1.13.1", | ||
"version": "1.14.0", | ||
"author": "Trent Mick <trentm@gmail.com> (http://trentm.com)", | ||
@@ -6,0 +6,0 @@ "keywords": ["option", "parser", "parsing", "cli", "command", "args", |
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
68528
961