better -help...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-08-02 04:22:04 +03:00
parent 4699e0434e
commit 54b2b93ce3
2 changed files with 14 additions and 7 deletions

19
argv.js
View File

@ -544,16 +544,23 @@ object.Constructor('Parser', {
var sep = this.helpArgumentSeparator || ', ' var sep = this.helpArgumentSeparator || ', '
var short = this.helpShortOptionSize || 1 var short = this.helpShortOptionSize || 1
var expandVars = this.expandTextVars.bind(this) var expandVars = this.expandTextVars.bind(this)
var formDoc = function(doc, handler){ var formDoc = function(doc, handler, arg){
var info = [ var info = [
...(handler.required ? ...(handler.required ?
['Required'] ['required']
: []),
...(handler.valueRequired ?
['required value']
: []), : []),
...('default' in handler ? ...('default' in handler ?
[`Default: ${handler.default}`] [`default: ${handler.default}`]
: []), : []),
...(handler.env ? ...(handler.env ?
[`Env: \$${handler.env}`] [`env: \$${handler.env}`]
: []),
...(handler instanceof Parser ?
//[`more: ${ that.scriptName } ${ arg.slice(1) } -h`]
[`more: .. ${ arg.slice(1) } -h`]
: []), : []),
].join(', ') ].join(', ')
return [doc.replace(/\\\*/g, '*'), return [doc.replace(/\\\*/g, '*'),
@ -622,7 +629,7 @@ object.Constructor('Parser', {
[arg] [arg]
: [])] : [])]
.join(that.helpValueSeparator), .join(that.helpValueSeparator),
...formDoc(doc, handler) ] })), ...formDoc(doc, handler, opts.slice(-1)[0]) ] })),
// dynamic options... // dynamic options...
...section('Dynamic options', ...section('Dynamic options',
(this['-*'] && this['-*'].section_doc) ? (this['-*'] && this['-*'].section_doc) ?
@ -642,7 +649,7 @@ object.Constructor('Parser', {
[arg] [arg]
: [])] : [])]
.join(that.helpValueSeparator), .join(that.helpValueSeparator),
...formDoc(doc, handler) ] })), ...formDoc(doc, handler, cmd.slice(-1)[0]) ] })),
// dynamic commands... // dynamic commands...
...section('Dynamic commands', ...section('Dynamic commands',
(this['@*'] && this['@*'].section_doc) ? (this['@*'] && this['@*'].section_doc) ?

View File

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