args
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -167,3 +167,3 @@ 'use strict'; | ||
default: | ||
return false; | ||
return ['']; | ||
} | ||
@@ -224,3 +224,3 @@ } | ||
for (const option of this.details.options) { | ||
if (!option.defaultValue) { | ||
if (typeof option.defaultValue === 'undefined') { | ||
continue; | ||
@@ -305,3 +305,3 @@ } | ||
for (const item of items) { | ||
let usage = item.usage; | ||
let { usage, description, defaultValue } = item; | ||
const difference = longest - usage.length; | ||
@@ -313,3 +313,10 @@ | ||
// Add some space around it as well | ||
parts.push(' ' + _chalk2.default.yellow(usage) + ' ' + _chalk2.default.dim(item.description)); | ||
if (typeof defaultValue !== 'undefined') { | ||
if (typeof defaultValue === 'boolean') { | ||
description += ` (${ defaultValue ? 'enabled' : 'disabled' } by default)`; | ||
} else { | ||
description += ` (defaults to ${ JSON.stringify(defaultValue) })`; | ||
} | ||
} | ||
parts.push(' ' + _chalk2.default.yellow(usage) + ' ' + _chalk2.default.dim(description)); | ||
} | ||
@@ -367,3 +374,3 @@ | ||
// If it exists, register it as a default option | ||
this.option('version', 'Output the version number', version); | ||
this.option('version', 'Output the version number'); | ||
@@ -411,3 +418,3 @@ // And immediately output it if used in command line | ||
// Parse arguments using minimist | ||
this.raw = (0, _minimist2.default)(argv.slice(1)); | ||
this.raw = (0, _minimist2.default)(argv.slice(1), this.config.minimist); | ||
this.binary = _path2.default.basename(this.raw._[0]); | ||
@@ -414,0 +421,0 @@ |
{ | ||
"name": "args", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Minimal toolkit for building CLIs", | ||
@@ -51,3 +51,3 @@ "main": "dist/index.js", | ||
"rules": { | ||
"xo/no-process-exit": 0, | ||
"unicorn/no-process-exit": 0, | ||
"max-lines": 0, | ||
@@ -64,10 +64,10 @@ "ava/no-ignored-test-files": 0 | ||
"devDependencies": { | ||
"ava": "^0.16.0", | ||
"ava": "^0.17.0", | ||
"babel-plugin-add-module-exports": "^0.2.0", | ||
"babel-plugin-transform-es2015-modules-commonjs": "^6.11.5", | ||
"execa": "^0.4.0", | ||
"execa": "^0.5.0", | ||
"gulp": "^3.9.1", | ||
"gulp-babel": "^6.1.2", | ||
"gulp-cached": "^1.1.0", | ||
"xo": "^0.16.0" | ||
"xo": "^0.17.0" | ||
}, | ||
@@ -74,0 +74,0 @@ "dependencies": { |
@@ -25,3 +25,3 @@ # args | ||
```bash | ||
npm install --save args | ||
$ npm install --save args | ||
``` | ||
@@ -41,3 +41,2 @@ | ||
// No magic globals here | ||
const flags = args.parse(process.argv) | ||
@@ -65,4 +64,4 @@ ``` | ||
serve, s Serve your static site | ||
help Display help | ||
serve, s Serve your static site | ||
help Display help | ||
@@ -121,5 +120,5 @@ Options: | ||
``` | ||
Using an initializer is currently only recommended if your command doesn't need special/different options than the binary in which you're defining it. The reason for this is that the "options" argument of the upper function will contain the options registered within the current binary. | ||
- **aliases:** Takes in an array of aliases which can be used to run the command. | ||
@@ -172,2 +171,3 @@ | ||
| value | Suffix for the "Usage" section of the usage information ([example](https://github.com/leo/args/issues/13)) | null | String | | ||
| minimist | Additional parsing options to pass to minimist, see [minimist docs](https://github.com/substack/minimist) for details | undefined | Object | | ||
@@ -174,0 +174,0 @@ You can pass the configuration object as the second paramater of [.parse()](#parseargv-options). |
24381
396