diff --git a/README.md b/README.md index 7d164b2..ab71178 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ This code is an evolution of that parser. - Reasonable defaults: - `-help` – generate and print help - `-version` – print version + - `-quiet` – suppress printing - `-` – stop argument processing - Extensible: - Hooks for dynamic option/command handling @@ -538,7 +539,8 @@ This will turn quiet mode on. In quiet mode [`.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` diff --git a/argv.js b/argv.js index a0dfa36..2cd0e15 100644 --- a/argv.js +++ b/argv.js @@ -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 diff --git a/package.json b/package.json index c6a1d2b..d2941ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-argv", - "version": "2.7.0", + "version": "2.7.1", "description": "simple argv parser", "main": "argv.js", "scripts": {