bugfix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-08-01 21:17:18 +03:00
parent 4fe9837881
commit 88790b9441
2 changed files with 8 additions and 7 deletions

13
argv.js
View File

@ -448,9 +448,10 @@ object.Constructor('Parser', {
// common tests...
isCommand: function(str){
return this.commandInputPattern.test(str)
return (str == ''
|| this.commandInputPattern.test(str))
&& ((COMMAND_PREFIX + str) in this
|| this['@*']) },
|| !!this['@*']) },
hasArgument: function(handler){
handler = typeof(handler) == typeof('str') ?
this.handler(handler)[1]
@ -876,8 +877,6 @@ object.Constructor('Parser', {
// all the parse data...
// NOTE: this (i.e. parser) can be used as a nested command/option
// handler...
//
// XXX BUG: can't pass "" as value...
__call__: function(context, argv, main, root_value){
var parsed = Object.create(this)
var opt_pattern = parsed.optionInputPattern
@ -925,14 +924,16 @@ object.Constructor('Parser', {
: arg.split(/=/)
// get value...
value = value == null ?
(((parsed.hasArgument(handler)
((parsed.hasArgument(handler)
&& rest.length > 0
&& !opt_pattern.test(rest[0])) ?
rest.shift()
: (typeof(process) != 'undefined' && handler.env) ?
process.env[handler.env.replace(/^\$/, '')]
: value)
|| handler.default)
: value
value = value == null ?
handler.default
: value
// value conversion...
value = (value != null

View File

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