cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-07-28 01:45:59 +03:00
parent 09be10556f
commit 8c4f7a6cf2

21
argv.js
View File

@ -43,6 +43,7 @@ module.ParserError =
// statically... // statically...
get name(){ get name(){
return this.constructor.name }, }) return this.constructor.name }, })
module.ParserTypeError = module.ParserTypeError =
object.Constructor('ParserTypeError', module.ParserError, {}) object.Constructor('ParserTypeError', module.ParserError, {})
module.ParserValueError = module.ParserValueError =
@ -215,18 +216,8 @@ function(name, pre, post){
// is handled as an option, no matter what the prefix, so different // is handled as an option, no matter what the prefix, so different
// prefixes can be handled by the handler by checking the key argument. // prefixes can be handled by the handler by checking the key argument.
// currently both '-' and '+' are supported. // currently both '-' and '+' are supported.
//
// NOTE: essentially this parser is a very basic stack language... // NOTE: essentially this parser is a very basic stack language...
// //
//
// XXX FEATURE (DELAYED): handle <scriptName>-<command> 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 should type handlers produce errors???
// XXX should -help work for any command? ..not just nested parsers? // XXX should -help work for any command? ..not just nested parsers?
// ...should we indicate which thinks have more "-help"?? // ...should we indicate which thinks have more "-help"??
var Parser = var Parser =
@ -270,7 +261,7 @@ object.Constructor('Parser', {
}, { }, {
// config... // config...
splitOptions: true, //
optionPrefix: '-', optionPrefix: '-',
commandPrefix: '@', commandPrefix: '@',
// NOTE: this must contain two goups the first is the prefix and the // NOTE: this must contain two goups the first is the prefix and the
@ -280,6 +271,8 @@ object.Constructor('Parser', {
optionInputPattern: /^([+-])\1?([^+-].*|)$/, optionInputPattern: /^([+-])\1?([^+-].*|)$/,
commandInputPattern: /^([^-].*)$/, commandInputPattern: /^([^-].*)$/,
splitOptions: true,
// instance stuff... // instance stuff...
// XXX do we need all three??? // XXX do we need all three???
script: null, script: null,
@ -454,6 +447,12 @@ object.Constructor('Parser', {
// \ // \
// +----------------------- .helpShortOptionSize (2 chars) // +----------------------- .helpShortOptionSize (2 chars)
// //
//
// NOTE: no effort was made to handle ALL cases gracefully, but in
// the most common cases this should work quite fine.
// common cases:
// - 1-2 flag variants (short/long) per flag
// - short-ish flag descriptions
helpColumnOffset: 3, helpColumnOffset: 3,
helpShortOptionSize: 2, helpShortOptionSize: 2,
helpColumnPrefix: '- ', helpColumnPrefix: '- ',