@oclif/parser
Advanced tools
Comparing version 3.8.4 to 3.8.5
@@ -0,1 +1,12 @@ | ||
## [3.8.5](https://github.com/oclif/parser/compare/v3.8.4...v3.8.5) (2020-05-15) | ||
### Bug Fixes | ||
* make `EnumFlagOptions#options` of type `T[]` instead of `string` ([#69](https://github.com/oclif/parser/issues/69)) ([2fefccb](https://github.com/oclif/parser/commit/2fefccb)) | ||
* move @oclif/errors to dependencies ([#71](https://github.com/oclif/parser/issues/71)) ([ff28cec](https://github.com/oclif/parser/commit/ff28cec)) | ||
* support `-` as an argument value ([#70](https://github.com/oclif/parser/issues/70)) ([73fed83](https://github.com/oclif/parser/commit/73fed83)) | ||
## [3.8.4](https://github.com/oclif/parser/compare/v3.8.3...v3.8.4) (2019-08-02) | ||
@@ -2,0 +13,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function newArg(arg) { | ||
return Object.assign({ parse: (i) => i }, arg, { required: !!arg.required }); | ||
return Object.assign({ parse: (i) => i }, arg, { required: Boolean(arg.required) }); | ||
} | ||
exports.newArg = newArg; |
@@ -9,3 +9,6 @@ "use strict"; | ||
enumerable: true, | ||
get: () => cache[name] || (cache[name] = fn()), | ||
get: () => { | ||
cache[name] = cache[name] || fn(); | ||
return cache[name]; | ||
}, | ||
}); | ||
@@ -12,0 +15,0 @@ return this; |
@@ -8,4 +8,7 @@ "use strict"; | ||
exports.CLIError = errors_2.CLIError; | ||
// eslint-disable-next-line new-cap | ||
const m = deps_1.default() | ||
// eslint-disable-next-line node/no-missing-require | ||
.add('help', () => require('./help')) | ||
// eslint-disable-next-line node/no-missing-require | ||
.add('list', () => require('./list')); | ||
@@ -24,3 +27,3 @@ class CLIParseError extends errors_1.CLIError { | ||
const namedArgs = args.filter(a => a.name); | ||
if (namedArgs.length) { | ||
if (namedArgs.length > 0) { | ||
const list = m.list.renderList(namedArgs.map(a => [`${a.name} (${a.required ? 'required' : 'optional'})`, a.description])); | ||
@@ -38,3 +41,3 @@ message += `:\n${list}`; | ||
const namedArgs = args.filter(a => a.name); | ||
if (namedArgs.length) { | ||
if (namedArgs.length > 0) { | ||
const list = m.list.renderList(namedArgs.map(a => [a.name, a.description])); | ||
@@ -41,0 +44,0 @@ message += `:\n${list}`; |
@@ -52,3 +52,3 @@ import { AlphabetLowercase, AlphabetUppercase } from './alphabet'; | ||
export declare type EnumFlagOptions<T> = Partial<IOptionFlag<T>> & { | ||
options: string[]; | ||
options: T[]; | ||
}; | ||
@@ -55,0 +55,0 @@ export declare type IFlag<T> = IBooleanFlag<T> | IOptionFlag<T>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
return (options = {}) => { | ||
return Object.assign({ parse: (i, _) => i }, defaults, options, { input: [], multiple: !!options.multiple, type: 'option' }); | ||
return Object.assign({ parse: (i, _) => i }, defaults, options, { input: [], multiple: Boolean(options.multiple), type: 'option' }); | ||
}; | ||
@@ -12,3 +12,3 @@ } | ||
function boolean(options = {}) { | ||
return Object.assign({ parse: (b, _) => b }, options, { allowNo: !!options.allowNo, type: 'boolean' }); | ||
return Object.assign({ parse: (b, _) => b }, options, { allowNo: Boolean(options.allowNo), type: 'boolean' }); | ||
} | ||
@@ -18,3 +18,3 @@ exports.boolean = boolean; | ||
parse: input => { | ||
if (!/^-?[0-9]+$/.test(input)) | ||
if (!/^-?\d+$/.test(input)) | ||
throw new Error(`Expected an integer but received: ${input}`); | ||
@@ -21,0 +21,0 @@ return parseInt(input, 10); |
@@ -5,4 +5,6 @@ "use strict"; | ||
const deps_1 = tslib_1.__importDefault(require("./deps")); | ||
// eslint-disable-next-line new-cap | ||
const m = deps_1.default() | ||
.add('chalk', () => require('chalk')) | ||
// eslint-disable-next-line node/no-missing-require | ||
.add('util', () => require('./util')); | ||
@@ -29,3 +31,3 @@ function flagUsage(flag, options = {}) { | ||
function flagUsages(flags, options = {}) { | ||
if (!flags.length) | ||
if (flags.length === 0) | ||
return []; | ||
@@ -32,0 +34,0 @@ const { sortBy } = m.util; |
@@ -13,3 +13,5 @@ "use strict"; | ||
exports.flagUsages = help_1.flagUsages; | ||
// eslint-disable-next-line new-cap | ||
const m = deps_1.default() | ||
// eslint-disable-next-line node/no-missing-require | ||
.add('validate', () => require('./validate').validate); | ||
@@ -16,0 +18,0 @@ function parse(argv, options) { |
@@ -6,11 +6,15 @@ "use strict"; | ||
const deps_1 = tslib_1.__importDefault(require("./deps")); | ||
// eslint-disable-next-line new-cap | ||
const m = deps_1.default() | ||
// eslint-disable-next-line node/no-missing-require | ||
.add('errors', () => require('./errors')) | ||
// eslint-disable-next-line node/no-missing-require | ||
.add('util', () => require('./util')); | ||
let debug; | ||
try { | ||
// eslint-disable-next-line no-negated-condition | ||
if (process.env.CLI_FLAGS_DEBUG !== '1') | ||
debug = () => { }; | ||
else | ||
// tslint:disable-next-line no-implicit-dependencies | ||
// eslint-disable-next-line node/no-extraneous-require | ||
debug = require('debug')('@oclif/parser'); | ||
@@ -91,3 +95,3 @@ } | ||
const input = this.argv.shift(); | ||
if (parsingFlags && input.startsWith('-')) { | ||
if (parsingFlags && input.startsWith('-') && input !== '-') { | ||
// attempt to parse as arg | ||
@@ -122,3 +126,3 @@ if (this.input['--'] !== false && input === '--') { | ||
raw: this.raw, | ||
metadata: this.metaData | ||
metadata: this.metaData, | ||
}; | ||
@@ -170,3 +174,3 @@ } | ||
if (flag.type === 'option' && flag.env) { | ||
let input = process.env[flag.env]; | ||
const input = process.env[flag.env]; | ||
if (input) | ||
@@ -204,11 +208,9 @@ flags[k] = flag.parse(input, this.context); | ||
} | ||
else { | ||
if ('default' in arg) { | ||
if (typeof arg.default === 'function') { | ||
args[i] = arg.default(); | ||
} | ||
else { | ||
args[i] = arg.default; | ||
} | ||
else if ('default' in arg) { | ||
if (typeof arg.default === 'function') { | ||
args[i] = arg.default(); | ||
} | ||
else { | ||
args[i] = arg.default; | ||
} | ||
} | ||
@@ -219,9 +221,9 @@ } | ||
_debugOutput(args, flags, argv) { | ||
if (argv.length) { | ||
if (argv.length > 0) { | ||
debug('argv: %o', argv); | ||
} | ||
if (Object.keys(args).length) { | ||
if (Object.keys(args).length > 0) { | ||
debug('args: %o', args); | ||
} | ||
if (Object.keys(flags).length) { | ||
if (Object.keys(flags).length > 0) { | ||
debug('flags: %o', flags); | ||
@@ -232,6 +234,6 @@ } | ||
debug('input: %s', this.argv.join(' ')); | ||
if (this.input.args.length) { | ||
if (this.input.args.length > 0) { | ||
debug('available args: %s', this.input.args.map(a => a.name).join(' ')); | ||
} | ||
if (!Object.keys(this.input.flags).length) | ||
if (Object.keys(this.input.flags).length === 0) | ||
return; | ||
@@ -238,0 +240,0 @@ debug('available flags: %s', Object.keys(this.input.flags) |
@@ -1,2 +0,2 @@ | ||
export declare let stdtermwidth: number; | ||
export declare let errtermwidth: number; | ||
export declare const stdtermwidth: number; | ||
export declare const errtermwidth: number; |
@@ -14,4 +14,4 @@ "use strict"; | ||
let max; | ||
for (let cur of arr) { | ||
let i = fn(cur); | ||
for (const cur of arr) { | ||
const i = fn(cur); | ||
if (!max || i > max.i) { | ||
@@ -37,3 +37,3 @@ max = { i, element: cur }; | ||
return 0; | ||
let diff = compare(a[0], b[0]); | ||
const diff = compare(a[0], b[0]); | ||
if (diff !== 0) | ||
@@ -40,0 +40,0 @@ return diff; |
@@ -12,3 +12,3 @@ "use strict"; | ||
} | ||
let missingRequiredArgs = []; | ||
const missingRequiredArgs = []; | ||
let hasOptional = false; | ||
@@ -29,3 +29,3 @@ parse.input.args.forEach((arg, index) => { | ||
}); | ||
if (missingRequiredArgs.length) { | ||
if (missingRequiredArgs.length > 0) { | ||
throw new errors_2.RequiredArgsError({ parse, args: missingRequiredArgs }); | ||
@@ -35,5 +35,5 @@ } | ||
function validateFlags() { | ||
for (let [name, flag] of Object.entries(parse.input.flags)) { | ||
for (const [name, flag] of Object.entries(parse.input.flags)) { | ||
if (parse.output.flags[name] !== undefined) { | ||
for (let also of flag.dependsOn || []) { | ||
for (const also of flag.dependsOn || []) { | ||
if (!parse.output.flags[also]) { | ||
@@ -43,3 +43,3 @@ throw new errors_1.CLIError(`--${also}= must also be provided when using --${name}=`); | ||
} | ||
for (let also of flag.exclusive || []) { | ||
for (const also of flag.exclusive || []) { | ||
// do not enforce exclusivity for flags that were defaulted | ||
@@ -55,6 +55,4 @@ if (parse.output.metadata.flags[also] && parse.output.metadata.flags[also].setFromDefault) | ||
} | ||
else { | ||
if (flag.required) | ||
throw new errors_2.RequiredFlagError({ parse, flag }); | ||
} | ||
else if (flag.required) | ||
throw new errors_2.RequiredFlagError({ parse, flag }); | ||
} | ||
@@ -61,0 +59,0 @@ } |
{ | ||
"name": "@oclif/parser", | ||
"description": "arg and flag parser for oclif", | ||
"version": "3.8.4", | ||
"version": "3.8.5", | ||
"author": "Jeff Dickey @jdxcode", | ||
"bugs": "https://github.com/oclif/parser/issues", | ||
"dependencies": { | ||
"@oclif/errors": "^1.2.2", | ||
"@oclif/linewrap": "^1.0.0", | ||
@@ -13,4 +14,2 @@ "chalk": "^2.4.2", | ||
"devDependencies": { | ||
"@oclif/errors": "^1.2.2", | ||
"@oclif/tslint": "^3.1.1", | ||
"@types/chai": "^4.1.7", | ||
@@ -24,7 +23,7 @@ "@types/mocha": "^5.2.6", | ||
"conventional-changelog-cli": "^2.0.17", | ||
"eslint": "^5.16.0", | ||
"eslint": "^6.6.0", | ||
"eslint-config-oclif": "^3.1.0", | ||
"eslint-config-oclif-typescript": "^0.1.0", | ||
"mocha": "^6.1.4", | ||
"ts-node": "^8.1.0", | ||
"tslint": "^5.16.0", | ||
"typescript": "^3.4.5" | ||
@@ -47,9 +46,10 @@ }, | ||
"build": "rm -rf lib && tsc", | ||
"lint": "yarn run build && eslint . && tsc -p test --noEmit && tslint -p test", | ||
"posttest": "yarn run lint", | ||
"lint": "tsc -p test --noEmit && eslint . --ext .ts --config .eslintrc", | ||
"posttest": "yarn lint", | ||
"prepublishOnly": "yarn run build", | ||
"test": "mocha --forbid-only \"test/**/*.test.ts\"", | ||
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md" | ||
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md", | ||
"pretest": "yarn run build" | ||
}, | ||
"types": "lib/index.d.ts" | ||
} |
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
48302
14
871
4
+ Added@oclif/errors@^1.2.2
+ Added@oclif/errors@1.3.6(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedclean-stack@3.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescape-string-regexp@4.0.0(transitive)
+ Addedfs-extra@8.1.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedindent-string@4.0.0(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addeduniversalify@0.1.2(transitive)
+ Addedwrap-ansi@7.0.0(transitive)