@oclif/parser
Advanced tools
Comparing version 3.2.11 to 3.2.12
@@ -0,1 +1,9 @@ | ||
<a name="3.2.12"></a> | ||
## [3.2.12](https://github.com/oclif/parser/compare/9c5fb0ff7b17b10a6b15def83dddb00944ff4867...v3.2.12) (2018-04-09) | ||
### Performance Improvements | ||
* lazy-load deps ([fbbfbf0](https://github.com/oclif/parser/commit/fbbfbf0)) | ||
<a name="3.2.11"></a> | ||
@@ -2,0 +10,0 @@ ## [3.2.11](https://github.com/oclif/parser/compare/e6e881fd2f1f7161830be965cf194dc5b99ba3ff...v3.2.11) (2018-04-06) |
@@ -5,2 +5,3 @@ import { CLIError } from '@oclif/errors'; | ||
import { ParserInput, ParserOutput } from './parse'; | ||
export { CLIError } from '@oclif/errors'; | ||
export interface ICLIParseErrorOptions { | ||
@@ -7,0 +8,0 @@ parse: { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const errors_1 = require("@oclif/errors"); | ||
const help_1 = require("./help"); | ||
const list_1 = require("./list"); | ||
const deps_1 = require("./deps"); | ||
var errors_2 = require("@oclif/errors"); | ||
exports.CLIError = errors_2.CLIError; | ||
const m = deps_1.default() | ||
.add('help', () => require('./help')) | ||
.add('list', () => require('./list')); | ||
class CLIParseError extends errors_1.CLIError { | ||
@@ -19,3 +23,3 @@ constructor(options) { | ||
if (namedArgs.length) { | ||
const list = list_1.renderList(namedArgs.map(a => [a.name, a.description])); | ||
const list = m.list.renderList(namedArgs.map(a => [a.name, a.description])); | ||
message += `:\n${list}`; | ||
@@ -30,3 +34,3 @@ } | ||
constructor({ flags, parse }) { | ||
const usage = list_1.renderList(help_1.flagUsages(flags, { displayRequired: false })); | ||
const usage = m.list.renderList(m.help.flagUsages(flags, { displayRequired: false })); | ||
const message = `Missing required flag${flags.length === 1 ? '' : 's'}:\n${usage}`; | ||
@@ -33,0 +37,0 @@ super({ parse, message }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const chalk_1 = require("chalk"); | ||
const util_1 = require("./util"); | ||
function dim(s) { | ||
if (chalk_1.default) | ||
return chalk_1.default.dim(s); | ||
return s; | ||
} | ||
const deps_1 = require("./deps"); | ||
const m = deps_1.default() | ||
.add('chalk', () => require('chalk')) | ||
.add('util', () => require('./util')); | ||
function flagUsage(flag, options = {}) { | ||
@@ -20,3 +17,3 @@ const label = []; | ||
description = `(required) ${description}`; | ||
description = description ? dim(description) : undefined; | ||
description = description ? m.chalk.dim(description) : undefined; | ||
return [` ${label.join(',').trim()}${usage}`, description]; | ||
@@ -28,5 +25,6 @@ } | ||
return []; | ||
return util_1.sortBy(flags, f => [f.char ? -1 : 1, f.char, f.name]) | ||
const { sortBy } = m.util; | ||
return sortBy(flags, f => [f.char ? -1 : 1, f.char, f.name]) | ||
.map(f => flagUsage(f, options)); | ||
} | ||
exports.flagUsages = flagUsages; |
@@ -9,5 +9,7 @@ "use strict"; | ||
exports.flags = flags; | ||
const validate_1 = require("./validate"); | ||
var help_1 = require("./help"); | ||
exports.flagUsages = help_1.flagUsages; | ||
const deps_1 = require("./deps"); | ||
const m = deps_1.default() | ||
.add('validate', () => require('./validate').validate); | ||
function parse(argv, options) { | ||
@@ -24,5 +26,5 @@ const input = { | ||
const output = parser.parse(); | ||
validate_1.validate({ input, output }); | ||
m.validate({ input, output }); | ||
return output; | ||
} | ||
exports.parse = parse; |
"use strict"; | ||
// tslint:disable interface-over-type-literal | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const errors_1 = require("@oclif/errors"); | ||
const Errors = require("./errors"); | ||
const util_1 = require("./util"); | ||
const deps_1 = require("./deps"); | ||
const m = deps_1.default() | ||
.add('errors', () => require('./errors')) | ||
.add('util', () => require('./util')); | ||
let debug; | ||
@@ -22,6 +23,7 @@ try { | ||
this.raw = []; | ||
const { pickBy } = m.util; | ||
this.context = input.context || {}; | ||
this.argv = input.argv.slice(0); | ||
this._setNames(); | ||
this.booleanFlags = util_1.pickBy(input.flags, f => f.type === 'boolean'); | ||
this.booleanFlags = pickBy(input.flags, f => f.type === 'boolean'); | ||
} | ||
@@ -70,3 +72,3 @@ parse() { | ||
if (!input) { | ||
throw new errors_1.CLIError(`Flag --${name} expects a value`); | ||
throw new m.errors.CLIError(`Flag --${name} expects a value`); | ||
} | ||
@@ -128,3 +130,3 @@ this.raw.push({ type: 'flag', flag: flag.name, input }); | ||
if (!flag) | ||
throw new errors_1.CLIError(`Unexpected flag ${token.flag}`); | ||
throw new m.errors.CLIError(`Unexpected flag ${token.flag}`); | ||
if (flag.type === 'boolean') { | ||
@@ -142,3 +144,3 @@ if (token.input === `--no-${flag.name}`) { | ||
if (flag.options && !flag.options.includes(input)) { | ||
throw new Errors.FlagInvalidOptionError(flag, input); | ||
throw new m.errors.FlagInvalidOptionError(flag, input); | ||
} | ||
@@ -184,3 +186,3 @@ const value = flag.parse ? flag.parse(input, this.context) : input; | ||
if (arg.options && !arg.options.includes(token.input)) { | ||
throw new Errors.ArgInvalidOptionError(arg, token.input); | ||
throw new m.errors.ArgInvalidOptionError(arg, token.input); | ||
} | ||
@@ -187,0 +189,0 @@ args[i] = arg.parse(token.input); |
{ | ||
"name": "@oclif/parser", | ||
"description": "arg and flag parser for oclif", | ||
"version": "3.2.11", | ||
"version": "3.2.12", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -12,3 +12,3 @@ "bugs": "https://github.com/oclif/parser/issues", | ||
"devDependencies": { | ||
"@oclif/errors": "^1.0.3", | ||
"@oclif/errors": "^1.0.4", | ||
"@oclif/tslint": "^1.1.0", | ||
@@ -15,0 +15,0 @@ "@types/chai": "^4.1.2", |
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
37053
28
765