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) // (see '-?' for a usage example)
// NOTE: this will not handle anything outside of handler call // NOTE: this will not handle anything outside of handler call
handle: function(handler, rest, key, value, mode){ handle: function(handler, rest, key, value, mode){
var orig_key = key
// got flag as handler... // got flag as handler...
;[key, handler] = ;[key, handler] =
typeof(handler) == typeof('str') ? typeof(handler) == typeof('str') ?
@ -472,11 +473,12 @@ object.Constructor('Parser', {
return this.handlerDefault(handler, ...args) })) return this.handlerDefault(handler, ...args) }))
.call(this, .call(this,
rest, rest,
key, orig_key,
...(value != null ? ...(value != null ?
[value] [value]
: [])) : []))
// special-case: nested parser -> set results object to .<arg>... // special-case: nested parser -> set results object to .<arg>...
// XXX should we use key or orig_key here???
if(handler instanceof Parser){ if(handler instanceof Parser){
res.unhandled res.unhandled
&& this.unhandled.splice(this.unhandled.length, 0, ...res.unhandled) && this.unhandled.splice(this.unhandled.length, 0, ...res.unhandled)

View File

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