mirror of
https://github.com/flynx/argv.js.git
synced 2025-10-28 02:10:08 +00:00
added simple multiline option .doc support...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
b982314015
commit
a36f566f10
@ -162,6 +162,12 @@ to control further parsing and/or execution.
|
||||
#### `<option>.doc`
|
||||
|
||||
Option/command documentation string used in `-help`.
|
||||
```
|
||||
doc: <string> | <array-of-strings>,
|
||||
```
|
||||
|
||||
If an array of strings is given each string will be printed on a separate
|
||||
line.
|
||||
|
||||
If this is set to `false` the option will be hidden from `-help`.
|
||||
|
||||
|
||||
@ -246,7 +246,9 @@ but option context can matter (see: [Active options/commands](#active-optionscom
|
||||
|
||||
// option with a value...
|
||||
'-value': {
|
||||
doc: 'set .x to X',
|
||||
doc: [
|
||||
'set .x to X',
|
||||
'NOTE: .doc can be multiple lines'],
|
||||
|
||||
// 'X' (i.e. VALUE) is used to indicate the option value in -help
|
||||
// while 'x' (key) is the attribute where the value will be written...
|
||||
@ -520,6 +522,7 @@ Options:
|
||||
(default: some value)
|
||||
--flag - if given set .flag
|
||||
--value=X - set .x to X
|
||||
NOTE: .doc can be multiple lines
|
||||
(required value)
|
||||
-i=INT - pass an integer value
|
||||
--home=PATH - set home path
|
||||
|
||||
9
argv.js
9
argv.js
@ -585,6 +585,11 @@ object.Constructor('Parser', {
|
||||
var val_req = getValue(handler, 'valueRequired')[1]
|
||||
var env = getValue(handler, 'env')[1]
|
||||
|
||||
doc = (doc instanceof Array ?
|
||||
doc
|
||||
: [doc])
|
||||
.map(function(s){
|
||||
return s.replace(/\\\*/g, '*') })
|
||||
var info = [
|
||||
...(req ?
|
||||
['required']
|
||||
@ -603,7 +608,9 @@ object.Constructor('Parser', {
|
||||
[`more: .. ${ arg.slice(1) } -h`]
|
||||
: []),
|
||||
].join(', ')
|
||||
return [doc.replace(/\\\*/g, '*'),
|
||||
|
||||
return [
|
||||
...doc,
|
||||
...(info.length > 0 ?
|
||||
['('+ info +')']
|
||||
: [])] }
|
||||
|
||||
@ -22,7 +22,9 @@ argv.Parser({
|
||||
|
||||
// option with a value...
|
||||
'-value': {
|
||||
doc: 'set .x to X',
|
||||
doc: [
|
||||
'set .x to X',
|
||||
'NOTE: .doc can be multiple lies'],
|
||||
|
||||
// 'X' (i.e. VALUE) is used to indicate the option value in -help
|
||||
// while 'x' (key) is the attribute where the value will be written...
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-argv",
|
||||
"version": "2.11.5",
|
||||
"version": "2.12.0",
|
||||
"description": "simple argv parser",
|
||||
"main": "argv.js",
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user