minor fix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-07-28 03:39:05 +03:00
parent 3a8ab9508e
commit aa9a08258d
3 changed files with 12 additions and 4 deletions

View File

@ -32,6 +32,7 @@ This code is an evolution of that parser.
- Reasonable defaults:
- `-help` &ndash; generate and print help
- `-version` &ndash; print version
- `-quiet` &ndash; suppress printing
- `-` &ndash; stop argument processing
- Extensible:
- Hooks for dynamic option/command handling
@ -538,7 +539,8 @@ This will turn quiet mode on.
In quiet mode [`<parser>.print(..)`](#parserprint--parserprinterror) will
not print anything.
Passing [`--help`](#-h----help) will disable quiet mode and print normally.
Passing [`--help`](#-h----help) or [`--version`](#-v----version) will
disable quiet mode and print normally.
#### `-h` / `--help`

10
argv.js
View File

@ -484,8 +484,8 @@ object.Constructor('Parser', {
.replace(/\$VERSION/g, this.version || '0.0.0')
.replace(/\$SCRIPTNAME/g, this.scriptName) },
'-h': '-help',
// NOTE: this will set .quiet to false...
'-h': '-help',
'-help': {
doc: 'print this message and exit',
priority: 99,
@ -627,6 +627,7 @@ object.Constructor('Parser', {
// Version...
//
// NOTE: this will set .quiet to false...
version: undefined,
'-v': '-version',
@ -634,19 +635,24 @@ object.Constructor('Parser', {
doc: 'show $SCRIPTNAME verion and exit',
priority: 99,
handler: function(){
this.quiet = false
this.print(this.version || '0.0.0')
return module.STOP }, },
// Quiet mode...
//
quiet: undefined,
'-q': '-quiet',
'-quiet': {
priority: 99,
doc: 'quiet mode', },
// Stop processing arguments and continue into .then(..) handlers...
// Stop argument processing...
//
// This will trigger .then(..) handlers...
//
// If .then(..) does not handle rest in the nested context then this
// context will be returned to the parent context, effectively

View File

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