Skip to content
Myr

add parseArg to Argument class (#2359)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Mateus Silva · committed by GitHub · parent c15a2cb · Browse files · 2 files+7 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−6 removed

  • other:+7 added−6 removed

2 files+7 added−6 removed

modified:lib/command.js+5 added-5 removed
318 unmodified lines
319 * program.argument('[output-file]');320 *321 * @param {string} name322 * @param {string} [description]323 * @param {(Function|*)} [fn] - custom argument processing function323 * @param {(Function|*)} [parseArg] - custom argument processing function or default value324 * @param {*} [defaultValue]325 * @return {Command} `this` command for chaining326 */327 argument(name, description, fn, defaultValue) {327 argument(name, description, parseArg, defaultValue) {328 const argument = this.createArgument(name, description);329 if (typeof fn === 'function') {330 argument.default(defaultValue).argParser(fn);329 if (typeof parseArg === 'function') {330 argument.default(defaultValue).argParser(parseArg);331 } else {332 argument.default(fn);332 argument.default(parseArg);333 }334 this.addArgument(argument);335 return this;336 }
2326 unmodified lines
modified:typings/index.d.ts+2 added-1 removed
49 unmodified lines
50 required: boolean;51 variadic: boolean;52 defaultValue?: any;53 defaultValueDescription?: string;54 parseArg?: <T>(value: string, previous: T) => T;55 argChoices?: string[];5657 /**58 * Initialize a new command argument with the given name and description.
407 unmodified lines
466 */467 argument<T>(468 flags: string,469 description: string,469 fn: (value: string, previous: T) => T,470 parseArg: (value: string, previous: T) => T,471 defaultValue?: T,472 ): this;473 argument(name: string, description?: string, defaultValue?: unknown): this;474
572 unmodified lines