Comparing version 6.3.11 to 6.3.12
@@ -512,3 +512,3 @@ 'use strict'; | ||
if (option.required) { | ||
const hasNegated = this.options.some(o => o.negated && o.names.includes(option.name)); | ||
const hasNegated = options.some(o => o.negated && o.names.includes(option.name)); | ||
if (value === true || (value === false && !hasNegated)) { | ||
@@ -515,0 +515,0 @@ console.error(`error: option \`${option.rawName}\` value is missing`); |
{ | ||
"name": "cac", | ||
"version": "6.3.11", | ||
"version": "6.3.12", | ||
"description": "Simple yet powerful framework for building command-line apps.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -72,3 +72,3 @@ <img width="945" alt="2017-07-26 9 27 05" src="https://user-images.githubusercontent.com/8784712/28623641-373450f4-7249-11e7-854d-1b076dab274d.png"> | ||
cli.option('--type [type]', 'Choose a project type', { | ||
cli.option('--type <type>', 'Choose a project type', { | ||
default: 'node' | ||
@@ -90,4 +90,4 @@ }) | ||
cli.option('--type [type]', 'Choose a project type', { | ||
default: 'node' | ||
cli.option('--eslint [config]', 'Choose an ESLint config', { | ||
default: 'standard' | ||
}) | ||
@@ -137,3 +137,3 @@ cli.option('--name <name>', 'Provide your name') | ||
When using brackets in option name, angled brackets indicate that the option value is required, while sqaure bracket indicate that the value is optional. | ||
When using brackets in option name, angled brackets indicate that a string / number value is required, while sqaure bracket indicate that the value can also be `true`. | ||
@@ -147,9 +147,26 @@ ```js | ||
.action((folder, options) => { | ||
console.log(folder) | ||
console.log(options) | ||
// ... | ||
}) | ||
cli | ||
.command('build [project]', 'Build a project') | ||
.option('--out <dir>', 'Output directory') | ||
.action((folder, options) => { | ||
// ... | ||
}) | ||
cli.parse() | ||
``` | ||
To allow an option whose value is `false`, you need to manually speicfy a negated option: | ||
```js | ||
cli | ||
.command('build [project]', 'Build a project') | ||
.option('--no-config', 'Disable config file') | ||
.option('--config <path>', 'Use a custom config file') | ||
``` | ||
This will let CAC set the default value of `config` to true, and you can use `--no-config` flag to set it to `false`. | ||
### Variadic Arguments | ||
@@ -156,0 +173,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47374
465