From 5ca866263a294047541091fe3b5eacc7e090c430 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 29 Jun 2020 02:51:06 +0300 Subject: [PATCH] several minor fixes... Signed-off-by: Alex A. Naanou --- argv.js | 33 ++++++++++++++++++++++----------- package.json | 2 +- test.js | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/argv.js b/argv.js index 0dabb48..9a3440e 100644 --- a/argv.js +++ b/argv.js @@ -349,6 +349,16 @@ object.Constructor('Parser', { // post parsing callbacks... // + // .then(callback(unhandleed)) + // + // .stop(callback(arg)) + // + // .error(callback(arg)) + // + // + // XXX need to document the arguments to each handler/callback... + // XXX .then(..) passes the full list of unhandleed args including + // argv[0] and argv[1]... then: afterCallback('parsing'), stop: afterCallback('stop'), error: afterCallback('error'), @@ -366,15 +376,17 @@ object.Constructor('Parser', { var nested = false // default argv... - argv = argv == null ? - process.argv.slice() - : argv - // XXX ARGV: strip out the interpreter if it is given... + argv = (argv == null ? + process.argv + : argv) + .slice() + var rest = this.rest = argv.slice() + + // XXX ARGV: strip out the interpreter if it is given... (???) // nested command handler... // XXX the condition is a bit too strong... if(context instanceof Parser){ - var rest = this.rest = argv.slice() this.script = this.scriptName = context.scriptName +' '+ arguments[2] this.argv = [context.scriptName, this.scriptName, ...argv] @@ -382,7 +394,6 @@ object.Constructor('Parser', { // root parser... } else { - var rest = this.rest = argv.slice() this.argv = argv.slice() // XXX ARGV: revise this... // - when run from node -- [,