now .handle(..) passes the given key down the call...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-08-14 15:30:54 +03:00
parent a36f566f10
commit 258e0443e3
2 changed files with 4 additions and 2 deletions

View File

@ -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 .<arg>...
// XXX should we use key or orig_key here???
if(handler instanceof Parser){
res.unhandled
&& this.unhandled.splice(this.unhandled.length, 0, ...res.unhandled)

View File

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