From fd2eb0e0edbc5e6d88970bfd10ab7bce0d677585 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 20 Jul 2020 03:05:11 +0300 Subject: [PATCH] testing... Signed-off-by: Alex A. Naanou --- argv.js | 18 +++++------------- test.js | 5 +++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/argv.js b/argv.js index d2ec7df..8f4b43e 100644 --- a/argv.js +++ b/argv.js @@ -187,29 +187,21 @@ function(name, pre, post){ // // // +// NOTE: currently any "argument" that passes the .optionInputPattern test +// is handled as an option, no matter what the prefix, so different +// prefixes can be handled by the handler by checking the key argument. +// currently both '-' and '+' are supported. // // NOTE: essentially this parser is a very basic stack language... // XXX can we implement the whole thing directly as a stack language??? // // -// XXX FEATURE: handle - script calls... -// +// XXX FEATURE (DELAYED): handle - script calls... // XXX FEATURE (DELAYED): read metadata from package.json... // ...not clear which package json to get, needs more thought... // XXX FEATURE (DELAYED): handle multiple values per flag... // ...manually this is trivial, automating it would complicate things, // will think about it when we need this feature more than once... -// XXX FEATURE (DELAYED): multiple prefixes, like '+' and the like... -// ...one way to do this manualy now is to set the appropriate -// .optionInputPattern and handle the arg in the handler itself... -// ...not sure yet how to automate this: -// - prefix handler -- pass the prefix to a special handler and -// it decides what to do... -// -help -> this.handlePrefix('-', ...) -// - option prefix derived from arg prefix i.e. -// -help -> this['-help'](..) -// +help -> this['+help'](..) -// // // XXX add support for ParserError exception handling... // XXX should -help should work for any command? ..not just nested parsers? diff --git a/test.js b/test.js index a621416..e8c14d2 100644 --- a/test.js +++ b/test.js @@ -46,6 +46,11 @@ argv.Parser({ required: true, }, + '-prefix': { + doc: 'prefix test', + handler: function(opts, key, value){ + console.log('PREFIX:', key[0]) }, }, + '-value': { doc: 'Value option', arg: 'VALUE | valueValue',