Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-08-01 20:49:56 +03:00
parent 0418a830c8
commit 4fe9837881
2 changed files with 8 additions and 5 deletions

11
argv.js
View File

@ -876,6 +876,8 @@ object.Constructor('Parser', {
// all the parse data...
// NOTE: this (i.e. parser) can be used as a nested command/option
// handler...
//
// XXX BUG: can't pass "" as value...
__call__: function(context, argv, main, root_value){
var parsed = Object.create(this)
var opt_pattern = parsed.optionInputPattern
@ -923,10 +925,12 @@ object.Constructor('Parser', {
: arg.split(/=/)
// get value...
value = value == null ?
(((parsed.hasArgument(handler) && !opt_pattern.test(rest[0])) ?
(((parsed.hasArgument(handler)
&& rest.length > 0
&& !opt_pattern.test(rest[0])) ?
rest.shift()
: (typeof(process) != 'undefined' && handler.env) ?
process.env[handler.env]
process.env[handler.env.replace(/^\$/, '')]
: value)
|| handler.default)
: value
@ -1021,8 +1025,7 @@ object.Constructor('Parser', {
throw ParserError(`Unknown ${ type == 'opt' ? 'option' : 'command:' } $ARG`, arg) }
// mark/unmark handlers...
values instanceof Set
&& values.delete(handler)
values.delete(handler)
seen.add(handler)
// implicit options -- with .env and or .default set...

View File

@ -1,6 +1,6 @@
{
"name": "ig-argv",
"version": "2.9.0",
"version": "2.9.1",
"description": "simple argv parser",
"main": "argv.js",
"scripts": {