a bit better sub-command title style...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-01-25 01:33:57 +03:00
parent de92caa190
commit c9f99d9ce0
2 changed files with 10 additions and 4 deletions

12
argv.js
View File

@ -702,6 +702,8 @@ object.Constructor('Parser', {
footer: 'Written by: $AUTHOR\nVersion: $VERSION / License: $LICENSE',
helpExtendedCommandHeader: 'Command: $COMMAND',
// to disable set to false...
helpExtendedCommandHeaderUnderline: '-',
// NOTE: this supports but does not requires the 'colors' module...
// XXX should wrap long lines...
@ -970,14 +972,18 @@ object.Constructor('Parser', {
// doc...
if(this[n] instanceof Parser
&& this[n].doc !== false){
var title
this.print([
'',
'',
(this.helpExtendedCommandHeader
(title = (this.helpExtendedCommandHeader
?? 'Command: $COMMAND')
.replace(/\$COMMAND/g, n.slice(1)),
.replace(/\$COMMAND/g, n.slice(1))),
this.helpExtendedCommandHeaderUnderline ?
title.replace(/./g, this.helpExtendedCommandHeaderUnderline)
: [],
'',
].join('\n'))
].flat().join('\n'))
this.handle(n, ['-h=noFooter'], n.slice(1)) } }
// footer...

View File

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