@jackens/cli
Advanced tools
Comparing version 1.5.21 to 1.5.22
15
cli.js
@@ -30,3 +30,7 @@ /* ISC (c) 2018+ Jackens * https://github.com/jackens/cli */ | ||
if (is.string(option.long)) { | ||
config.optionsMap[option.long] = option | ||
if (option.long.length >= 2) { | ||
config.optionsMap[option.long] = option | ||
} else { | ||
option.long = undefined | ||
} | ||
} | ||
@@ -70,5 +74,8 @@ if (is.string(option.short)) { | ||
} | ||
[0, 1].forEach(function () { | ||
arg = arg.replace(/^-/, '') | ||
var option = config.optionsMap[arg] | ||
[true, false].forEach(function (isShortOption) { | ||
var $ = isShortOption ? arg.match(/^-(.)$/) : arg.match(/^--(.{2,})$/) | ||
if (!$) { | ||
return | ||
} | ||
var option = config.optionsMap[$[1]] | ||
if (!is.object(option)) { | ||
@@ -75,0 +82,0 @@ return |
@@ -6,6 +6,6 @@ { | ||
}, | ||
"description": "‘cli’ is lightweight command-line helper. Works in both Node.js and the browser ;)", | ||
"dependencies": { | ||
"@jackens/is": "^1.5.20" | ||
}, | ||
"description": "‘cli’ is lightweight command-line helper. Works in both Node.js and the browser ;)", | ||
"homepage": "https://github.com/jackens/cli#readme", | ||
@@ -22,3 +22,3 @@ "keywords": [ | ||
}, | ||
"version": "1.5.21" | ||
"version": "1.5.22" | ||
} |
## cli | ||
‘cli’ is lightweight command-line helper | ||
Works in both Node.js and the browser. | ||
‘cli’ is lightweight command-line helper. | ||
Works in both Node.js and the browser ;) | ||
@@ -50,3 +50,4 @@ ## Install | ||
}, { | ||
short: 'f', | ||
long: 'f', // will be converted to undefined | ||
short: 'foobar', // will be converted to ‘f’ | ||
info: '‘f’ as ‘foobar’' | ||
@@ -53,0 +54,0 @@ }, { |
8161
5
147
91