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)
|
- [Disabling or redefining a built-in option](#disabling-or-redefining-a-built-in-option)
|
||||||
- [`-` / `--`](#-----)
|
- [`-` / `--`](#-----)
|
||||||
- [`-*` / `@*`](#---)
|
- [`-*` / `@*`](#---)
|
||||||
|
- [`<parser>.delegateUnknownToParent`](#parserdelegateunknowntoparent)
|
||||||
- [`-v` / `--version`](#-v----version)
|
- [`-v` / `--version`](#-v----version)
|
||||||
- [`-q` / `--quiet`](#-q----quiet)
|
- [`-q` / `--quiet`](#-q----quiet)
|
||||||
- [`-h` / `--help`](#-h----help)
|
- [`-h` / `--help`](#-h----help)
|
||||||
@ -383,11 +384,22 @@ for example.
|
|||||||
|
|
||||||
Handle options/commands for which no definition is found.
|
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 `-*`.
|
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`
|
#### `-v` / `--version`
|
||||||
|
|
||||||
This will output the value of `.version` and exit.
|
This will output the value of `.version` and exit.
|
||||||
|
|||||||
4
argv.js
4
argv.js
@ -1082,8 +1082,8 @@ object.Constructor('Parser', {
|
|||||||
//section_doc: ...,
|
//section_doc: ...,
|
||||||
handler: function(_, key, value){
|
handler: function(_, key, value){
|
||||||
// delegate to parent...
|
// delegate to parent...
|
||||||
if(this.delegateUnknownToParent
|
if(this.parent
|
||||||
&& this.parent){
|
&& this.delegateUnknownToParent){
|
||||||
this.parent.rest.unshift(
|
this.parent.rest.unshift(
|
||||||
value === undefined ?
|
value === undefined ?
|
||||||
key
|
key
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-argv",
|
"name": "ig-argv",
|
||||||
"version": "2.17.0",
|
"version": "2.17.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