From 88790b94411b3ae83a629e4945d686a45ac7c463 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 1 Aug 2020 21:17:18 +0300 Subject: [PATCH] bugfix... Signed-off-by: Alex A. Naanou --- argv.js | 13 +++++++------ package.json | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/argv.js b/argv.js index c73d05a..6a0dbf9 100644 --- a/argv.js +++ b/argv.js @@ -448,9 +448,10 @@ object.Constructor('Parser', { // common tests... isCommand: function(str){ - return this.commandInputPattern.test(str) + return (str == '' + || this.commandInputPattern.test(str)) && ((COMMAND_PREFIX + str) in this - || this['@*']) }, + || !!this['@*']) }, hasArgument: function(handler){ handler = typeof(handler) == typeof('str') ? this.handler(handler)[1] @@ -876,8 +877,6 @@ 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 @@ -925,14 +924,16 @@ object.Constructor('Parser', { : arg.split(/=/) // get value... value = value == null ? - (((parsed.hasArgument(handler) + ((parsed.hasArgument(handler) && rest.length > 0 && !opt_pattern.test(rest[0])) ? rest.shift() : (typeof(process) != 'undefined' && handler.env) ? process.env[handler.env.replace(/^\$/, '')] : value) - || handler.default) + : value + value = value == null ? + handler.default : value // value conversion... value = (value != null diff --git a/package.json b/package.json index 281577d..c8026a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-argv", - "version": "2.9.1", + "version": "2.9.2", "description": "simple argv parser", "main": "argv.js", "scripts": {