From 258e0443e3bfb279a3ef39e613e2010ba482e37f Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 14 Aug 2020 15:30:54 +0300 Subject: [PATCH] now .handle(..) passes the given key down the call... Signed-off-by: Alex A. Naanou --- argv.js | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/argv.js b/argv.js index 5855560..dc90ab4 100644 --- a/argv.js +++ b/argv.js @@ -459,6 +459,7 @@ object.Constructor('Parser', { // (see '-?' for a usage example) // NOTE: this will not handle anything outside of handler call handle: function(handler, rest, key, value, mode){ + var orig_key = key // got flag as handler... ;[key, handler] = typeof(handler) == typeof('str') ? @@ -472,11 +473,12 @@ object.Constructor('Parser', { return this.handlerDefault(handler, ...args) })) .call(this, rest, - key, + orig_key, ...(value != null ? [value] : [])) // special-case: nested parser -> set results object to .... + // XXX should we use key or orig_key here??? if(handler instanceof Parser){ res.unhandled && this.unhandled.splice(this.unhandled.length, 0, ...res.unhandled) diff --git a/package.json b/package.json index 0f5c11f..2ff3ced 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-argv", - "version": "2.12.0", + "version": "2.13.0", "description": "simple argv parser", "main": "argv.js", "scripts": {