mirror of
https://github.com/flynx/argv.js.git
synced 2025-10-29 10:50:06 +00:00
notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
0418a830c8
commit
4fe9837881
11
argv.js
11
argv.js
@ -876,6 +876,8 @@ object.Constructor('Parser', {
|
|||||||
// all the parse data...
|
// all the parse data...
|
||||||
// NOTE: this (i.e. parser) can be used as a nested command/option
|
// NOTE: this (i.e. parser) can be used as a nested command/option
|
||||||
// handler...
|
// handler...
|
||||||
|
//
|
||||||
|
// XXX BUG: can't pass "" as value...
|
||||||
__call__: function(context, argv, main, root_value){
|
__call__: function(context, argv, main, root_value){
|
||||||
var parsed = Object.create(this)
|
var parsed = Object.create(this)
|
||||||
var opt_pattern = parsed.optionInputPattern
|
var opt_pattern = parsed.optionInputPattern
|
||||||
@ -923,10 +925,12 @@ object.Constructor('Parser', {
|
|||||||
: arg.split(/=/)
|
: arg.split(/=/)
|
||||||
// get value...
|
// get value...
|
||||||
value = value == null ?
|
value = value == null ?
|
||||||
(((parsed.hasArgument(handler) && !opt_pattern.test(rest[0])) ?
|
(((parsed.hasArgument(handler)
|
||||||
|
&& rest.length > 0
|
||||||
|
&& !opt_pattern.test(rest[0])) ?
|
||||||
rest.shift()
|
rest.shift()
|
||||||
: (typeof(process) != 'undefined' && handler.env) ?
|
: (typeof(process) != 'undefined' && handler.env) ?
|
||||||
process.env[handler.env]
|
process.env[handler.env.replace(/^\$/, '')]
|
||||||
: value)
|
: value)
|
||||||
|| handler.default)
|
|| handler.default)
|
||||||
: value
|
: value
|
||||||
@ -1021,8 +1025,7 @@ object.Constructor('Parser', {
|
|||||||
throw ParserError(`Unknown ${ type == 'opt' ? 'option' : 'command:' } $ARG`, arg) }
|
throw ParserError(`Unknown ${ type == 'opt' ? 'option' : 'command:' } $ARG`, arg) }
|
||||||
|
|
||||||
// mark/unmark handlers...
|
// mark/unmark handlers...
|
||||||
values instanceof Set
|
values.delete(handler)
|
||||||
&& values.delete(handler)
|
|
||||||
seen.add(handler)
|
seen.add(handler)
|
||||||
|
|
||||||
// implicit options -- with .env and or .default set...
|
// implicit options -- with .env and or .default set...
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-argv",
|
"name": "ig-argv",
|
||||||
"version": "2.9.0",
|
"version": "2.9.1",
|
||||||
"description": "simple argv parser",
|
"description": "simple argv parser",
|
||||||
"main": "argv.js",
|
"main": "argv.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user