mirror of
https://github.com/flynx/argv.js.git
synced 2025-10-28 10:20:09 +00:00
better docs + minor cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
cfaa901611
commit
4fc2e7fc5d
14
ADVANCED.md
14
ADVANCED.md
@ -28,6 +28,7 @@ For basics see [README.md](./README.md)
|
||||
- [Disabling or redefining a built-in option](#disabling-or-redefining-a-built-in-option)
|
||||
- [`-` / `--`](#-----)
|
||||
- [`-*` / `@*`](#---)
|
||||
- [`<parser>.delegateUnknownToParent`](#parserdelegateunknowntoparent)
|
||||
- [`-v` / `--version`](#-v----version)
|
||||
- [`-q` / `--quiet`](#-q----quiet)
|
||||
- [`-h` / `--help`](#-h----help)
|
||||
@ -383,11 +384,22 @@ for example.
|
||||
|
||||
Handle options/commands for which no definition is found.
|
||||
|
||||
By default `-*` will print an "unhandled option/command" error and terminate.
|
||||
By default `-*` will:
|
||||
- on root parser: print an "unhandled option/command" error and terminate.
|
||||
- on nested parser: delegate the option to the parent.
|
||||
|
||||
By default `@*` is an alias to `-*`.
|
||||
|
||||
|
||||
##### `<parser>.delegateUnknownToParent`
|
||||
|
||||
Controls the default behavior of a nested parser when encountering an unknown option.
|
||||
|
||||
If `true` (default) the option will be delegated to the parent parser. If `false`
|
||||
behave the same way as the root parser, i.e. printing an error.
|
||||
|
||||
|
||||
|
||||
#### `-v` / `--version`
|
||||
|
||||
This will output the value of `.version` and exit.
|
||||
|
||||
4
argv.js
4
argv.js
@ -1082,8 +1082,8 @@ object.Constructor('Parser', {
|
||||
//section_doc: ...,
|
||||
handler: function(_, key, value){
|
||||
// delegate to parent...
|
||||
if(this.delegateUnknownToParent
|
||||
&& this.parent){
|
||||
if(this.parent
|
||||
&& this.delegateUnknownToParent){
|
||||
this.parent.rest.unshift(
|
||||
value === undefined ?
|
||||
key
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-argv",
|
||||
"version": "2.17.0",
|
||||
"version": "2.17.1",
|
||||
"description": "simple argv parser",
|
||||
"main": "argv.js",
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user