Comparing version 8.1.2 to 9.0.0
@@ -35,3 +35,3 @@ import {PackageJson} from 'type-fest'; | ||
The key is the flag name and the value is an object with any of: | ||
The key is the flag name in camel-case and the value is an object with any of: | ||
@@ -46,2 +46,4 @@ - `type`: Type of value. (Possible values: `string` `boolean` `number`) | ||
Note that flags are always defined using a camel-case key (`myKey`), but will match arguments in kebab-case (`--my-key`). | ||
@example | ||
@@ -48,0 +50,0 @@ ``` |
11
index.js
@@ -6,2 +6,3 @@ 'use strict'; | ||
const camelCaseKeys = require('camelcase-keys'); | ||
const decamelize = require('decamelize'); | ||
const decamelizeKeys = require('decamelize-keys'); | ||
@@ -54,6 +55,13 @@ const trimNewlines = require('trim-newlines'); | ||
for (const flag of missingRequiredFlags) { | ||
console.error(`\t--${flag.key}${flag.alias ? `, -${flag.alias}` : ''}`); | ||
console.error(`\t--${decamelize(flag.key, '-')}${flag.alias ? `, -${flag.alias}` : ''}`); | ||
} | ||
}; | ||
const validateOptions = ({flags}) => { | ||
const invalidFlags = Object.keys(flags).filter(flagKey => flagKey.includes('-') && flagKey !== '--'); | ||
if (invalidFlags.length > 0) { | ||
throw new Error(`Flag keys may not contain '-': ${invalidFlags.join(', ')}`); | ||
} | ||
}; | ||
const reportUnknownFlags = unknownFlags => { | ||
@@ -130,2 +138,3 @@ console.error([ | ||
validateOptions(options); | ||
let parserOptions = { | ||
@@ -132,0 +141,0 @@ arguments: options.input, |
{ | ||
"name": "meow", | ||
"version": "8.1.2", | ||
"version": "9.0.0", | ||
"description": "CLI app helper", | ||
@@ -45,2 +45,3 @@ "license": "MIT", | ||
"camelcase-keys": "^6.2.2", | ||
"decamelize": "^1.2.0", | ||
"decamelize-keys": "^1.1.0", | ||
@@ -47,0 +48,0 @@ "hard-rejection": "^2.1.0", |
@@ -135,3 +135,3 @@ # meow | ||
The key is the flag name and the value is an object with any of: | ||
The key is the flag name in camel-case and the value is an object with any of: | ||
@@ -149,2 +149,4 @@ - `type`: Type of value. (Possible values: `string` `boolean` `number`) | ||
Note that flags are always defined using a camel-case key (`myKey`), but will match arguments in kebab-case (`--my-key`). | ||
Example: | ||
@@ -151,0 +153,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
24773
442
353
12
+ Addeddecamelize@^1.2.0