Comparing version 1.5.0 to 1.6.0
@@ -141,3 +141,5 @@ /** | ||
if (val.short) k = `${k}, -${val.short}` | ||
acc[k] = val.description | ||
let d = val.description | ||
if (val.default) d = `${d}\nDefault: ${val.default}.` | ||
acc[k] = d | ||
return acc | ||
@@ -169,2 +171,3 @@ }, {}) | ||
* @prop {boolean} [multiple=false] When using the `command` property, will parse the commands as an array. Default `false`. | ||
* @prop {string} [default] The default value for the argument. Does not actually set the value, only used in reducing the usage info (`argufy` bin on the other hand will set the default). | ||
* @prop {string} [description] The description to be used by `usually`. | ||
@@ -171,0 +174,0 @@ */ |
@@ -0,1 +1,8 @@ | ||
## 24 April 2019 | ||
### [1.6.0](https://github.com/artdecocode/argufy/compare/v1.5.0...v1.6.0) | ||
- [feature] Print the default value in `reduceUsage`. | ||
- [fix] Correctly apply integer and boolean default values to `get-args.js` output; don't escape `'` in back-ticks. | ||
## 17 April 2019 | ||
@@ -2,0 +9,0 @@ |
@@ -9,4 +9,4 @@ /* documentary types/index.xml */ | ||
/** | ||
* @typedef {{ short: (string|undefined), boolean: (boolean|undefined), number: (boolean|undefined), command: (boolean|undefined), multiple: (boolean|undefined), description: (string|undefined) }} | ||
* @typedef {{ short: (string|undefined), boolean: (boolean|undefined), number: (boolean|undefined), command: (boolean|undefined), multiple: (boolean|undefined), default: (string|undefined), description: (string|undefined) }} | ||
*/ | ||
_argufy.Flag |
{ | ||
"name": "argufy", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Parses Command Line Arguments To Node.JS CLI Programs, Keeps Them In Arguments.xml File To Paste Into README Documentation And Generate Google Closure Compatible Exports.", | ||
@@ -14,3 +14,3 @@ "main": "build", | ||
"lint": "eslint .", | ||
"doc": "NODE_DEBUG=doc doc documentary -o README.md", | ||
"doc": "NODE_DEBUG=doc doc -o README.md", | ||
"depack": "depack-dev src/argufy -p -c -a -o depack -s --externs externs.js", | ||
@@ -53,5 +53,5 @@ "d": "yarn-s d1 externs", | ||
"@wrote/write": "^1.0.4", | ||
"alamode": "^1.9.3", | ||
"alamode": "^2.0.0", | ||
"catchment": "^3.3.0", | ||
"documentary": "^1.23.4", | ||
"documentary": "^1.26.0", | ||
"erotic": "^2.1.1", | ||
@@ -62,5 +62,5 @@ "rexml": "^1.4.0", | ||
"yarn-s": "1.1.0", | ||
"zoroaster": "^3.11.5" | ||
"zoroaster": "^3.13.0" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -160,2 +160,3 @@ # argufy | ||
input The location of the `arguments.xml` file. | ||
Default: types/arguments.xml. | ||
--output, -o The destination where to save output. | ||
@@ -257,10 +258,11 @@ If not passed, prints to stdout. | ||
| Name | Type | Description | Default | | ||
| ----------- | --------- | ------------------------------------------------------------------------------------------------------------ | ------- | | ||
| short | _string_ | Shorthand for this argument, usually one letter. | - | | ||
| boolean | _boolean_ | Whether the flag is a boolean and does not require a value. | `false` | | ||
| number | _boolean_ | Specifies whether the flag should be parsed as a number. | `false` | | ||
| command | _boolean_ | If set to true, the value is read from the first argument passed to the CLI command (e.g., `$ cli command`). | `false` | | ||
| multiple | _boolean_ | When using the `command` property, will parse the commands as an array. | `false` | | ||
| description | _string_ | The description to be used by `usually`. | - | | ||
| Name | Type | Description | Default | | ||
| ----------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | ||
| short | <em>string</em> | Shorthand for this argument, usually one letter. | - | | ||
| boolean | <em>boolean</em> | Whether the flag is a boolean and does not require a value. | `false` | | ||
| number | <em>boolean</em> | Specifies whether the flag should be parsed as a number. | `false` | | ||
| command | <em>boolean</em> | If set to true, the value is read from the first argument passed to the CLI command (e.g., `$ cli command`). | `false` | | ||
| multiple | <em>boolean</em> | When using the `command` property, will parse the commands as an array. | `false` | | ||
| default | <em>string</em> | The default value for the argument. Does not actually set the value, only used in reducing the usage info (`argufy` bin on the other hand will set the default). | - | | ||
| description | <em>string</em> | The description to be used by `usually`. | - | | ||
@@ -280,3 +282,3 @@ <p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/4.svg?sanitize=true" width="20"></a></p> | ||
```js | ||
{ input: 'The location of the `arguments.xml` file.', | ||
{ input: 'The location of the `arguments.xml` file.\nDefault: types/arguments.xml.', | ||
'--output, -o': 'The destination where to save output.\nIf not passed, prints to stdout.', | ||
@@ -283,0 +285,0 @@ '--help, -h': 'Print the help information and exit.', |
@@ -57,10 +57,12 @@ import read from '@wrote/read' | ||
}) => { | ||
let codes = {} | ||
const d = description.replace(/`(.+)`/g, (m, code, i) => { | ||
codes[i] = code | ||
return `%%RESTREAM_REPLACE_${i}%%` | ||
}).replace(/'/g, '\\\'').replace(/\n\s*/g, '\\n'). | ||
replace(/%%RESTREAM_REPLACE_(\d+)%%/g, (m, i) => { | ||
return '`' + codes[i] + '`' | ||
}) | ||
// let codes = {} | ||
const d = description | ||
// .replace(/`(.+)`/g, (m, code, i) => { | ||
// codes[i] = code | ||
// return `%%RESTREAM_REPLACE_${i}%%` | ||
// }) | ||
.replace(/'/g, '\\\'').replace(/\n\s*/g, '\\n') | ||
// .replace(/%%RESTREAM_REPLACE_(\d+)%%/g, (m, i) => { | ||
// return '`' + codes[i] + '`' | ||
// }) | ||
let s = [] | ||
@@ -109,7 +111,11 @@ if (description) s.push(`description: '${d}'`) | ||
const n = name.replace(/-(.)/g, (m, l) => l.toUpperCase()) | ||
let ddef = `'${def}'` | ||
if (number || boolean) ddef = def | ||
const hasDef = def !== undefined | ||
// const ddef = number ? def : | ||
return `/** | ||
* ${description}${def ? ` Default \`${def}\`.` : ''} | ||
* ${description}${hasDef ? ` Default \`${def}\`.` : ''} | ||
*/ | ||
export const _${n} = /** @type {${type}} */ (args['${name}'])${ | ||
def ? ` || '${def}'` : ''}` | ||
hasDef ? ` || ${ddef}` : ''}` | ||
} |
@@ -141,3 +141,5 @@ /** | ||
if (val.short) k = `${k}, -${val.short}` | ||
acc[k] = val.description | ||
let d = val.description | ||
if (val.default) d = `${d}\nDefault: ${val.default}.` | ||
acc[k] = d | ||
return acc | ||
@@ -169,3 +171,4 @@ }, {}) | ||
* @prop {boolean} [multiple=false] When using the `command` property, will parse the commands as an array. Default `false`. | ||
* @prop {string} [default] The default value for the argument. Does not actually set the value, only used in reducing the usage info (`argufy` bin on the other hand will set the default). | ||
* @prop {string} [description] The description to be used by `usually`. | ||
*/ |
78675
889
293