mirror of
https://github.com/flynx/argv.js.git
synced 2025-12-20 02:21:41 +00:00
docs + fixes to reporting...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ed23022e83
commit
7e9e5e0b5c
12
README.md
12
README.md
@ -215,16 +215,20 @@ for example:
|
|||||||
### Basic options
|
### Basic options
|
||||||
|
|
||||||
These, if encountered, simply assign a value to an attribute on the parsed object.
|
These, if encountered, simply assign a value to an attribute on the parsed object.
|
||||||
|
This attribute's name is defined by the option name (without the prefix) or by
|
||||||
|
setting [`<option>.arg`](#optionarg)'s `<key>`.
|
||||||
|
|
||||||
Any option/command can be passed a value, either explicitly (e.g. `-opt=123`) or
|
Any option/command can be passed a value, either explicitly (e.g. `-opt=123`) or
|
||||||
implicitly by first setting `.arg` (see examples below) and and then passing `-opt 123`.
|
implicitly by first setting [`<option>.arg`](#optionarg)'s `<arg-name>` component
|
||||||
|
and and then passing `-opt 123`.
|
||||||
|
|
||||||
|
Option/command values can be set on the command-line as well as via
|
||||||
|
[`<option>.env`](./ADVANCED.md#optionenv) and/or
|
||||||
|
[`<option>.default`](./ADVANCED.md#optiondefault).
|
||||||
|
|
||||||
If option is given but no value is set, `undefined` is assigned to option
|
If option is given but no value is set, `undefined` is assigned to option
|
||||||
attribute on the parsed object to indicate that the option/command is present
|
attribute on the parsed object to indicate that the option/command is present
|
||||||
in the command-line.
|
in the command-line.
|
||||||
Note that values can be set on the command-line as well as via
|
|
||||||
[`<option>.env`](./ADVANCED.md#optionenv) and/or
|
|
||||||
[`<option>.default`](./ADVANCED.md#optiondefault) see examples below.
|
|
||||||
|
|
||||||
Note that repeating a basic option/command will overwrite the previous occurrences'
|
Note that repeating a basic option/command will overwrite the previous occurrences'
|
||||||
value unless `.collect` is set (see `-push` example below).
|
value unless `.collect` is set (see `-push` example below).
|
||||||
|
|||||||
6
argv.js
6
argv.js
@ -1005,17 +1005,17 @@ object.Constructor('Parser', {
|
|||||||
&& parsed.handleArgumentValue) ?
|
&& parsed.handleArgumentValue) ?
|
||||||
parsed.handleArgumentValue(handler, value)
|
parsed.handleArgumentValue(handler, value)
|
||||||
: value
|
: value
|
||||||
|
|
||||||
|
try {
|
||||||
// required value check...
|
// required value check...
|
||||||
if(handler.valueRequired && value == null){
|
if(handler.valueRequired && value == null){
|
||||||
throw module.ParserValueError('Value missing: ${ arg }=?') }
|
throw module.ParserValueError('Value missing: $ARG=?') }
|
||||||
|
|
||||||
// do not call the handler if value is implicitly undefined...
|
// do not call the handler if value is implicitly undefined...
|
||||||
if(value === undefined
|
if(value === undefined
|
||||||
&& mode == 'implicit'){
|
&& mode == 'implicit'){
|
||||||
return }
|
return }
|
||||||
|
|
||||||
// run handler...
|
|
||||||
try {
|
|
||||||
var res = parsed.handle(handler, rest, arg, value)
|
var res = parsed.handle(handler, rest, arg, value)
|
||||||
|
|
||||||
// update error object with current context's arg and rest...
|
// update error object with current context's arg and rest...
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-argv",
|
"name": "ig-argv",
|
||||||
"version": "2.11.0",
|
"version": "2.11.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