Comparing version 1.0.19 to 2.0.0
@@ -31,1 +31,2 @@ export declare type ParseFn<T> = (input: string) => T; | ||
export declare function newArg<T = string>(arg: IArg<string>): Arg<string>; | ||
export declare type Input = IArg<any>[]; |
@@ -19,38 +19,20 @@ import { AlphabetLowercase, AlphabetUppercase } from './alphabet'; | ||
} | ||
export interface IOptionFlagBase<T> extends IFlagBase { | ||
export interface IOptionFlag<T = string> extends IFlagBase { | ||
type: 'option'; | ||
default?: T | ((context: DefaultContext<T>) => T | undefined); | ||
parse: (input: string) => T; | ||
multiple: boolean; | ||
} | ||
export interface IOptionalFlag<T> extends IOptionFlagBase<T> { | ||
multiple: false; | ||
default?: T | ((context: DefaultContext<T>) => T | undefined); | ||
} | ||
export interface IRequiredFlag<T> extends IOptionFlagBase<T> { | ||
required: true; | ||
multiple: false; | ||
default?: undefined; | ||
} | ||
export interface IMultiOptionFlag<T> extends IOptionFlagBase<T> { | ||
multiple: true; | ||
default?: undefined; | ||
} | ||
export declare type IOptionFlag<T> = IOptionalFlag<T> | IRequiredFlag<T> | IMultiOptionFlag<T>; | ||
export declare type FlagBuilder<T> = { | ||
(options: Partial<IMultiOptionFlag<T>> & { | ||
multiple: true; | ||
}): IMultiOptionFlag<T>; | ||
(options: Partial<IRequiredFlag<T>> & { | ||
required: true; | ||
}): IRequiredFlag<T>; | ||
(options?: Partial<IOptionalFlag<T>>): IOptionalFlag<T>; | ||
}; | ||
export declare type Definition<T> = (options?: Partial<IOptionFlag<T>>) => IOptionFlag<T>; | ||
export declare function option<T = string>(defaults?: Partial<IOptionFlag<T>>): Definition<T>; | ||
export declare type IFlag<T> = IBooleanFlag | IOptionFlag<T>; | ||
export declare const flags: { | ||
boolean: (options?: Partial<IBooleanFlag>) => IBooleanFlag; | ||
integer: FlagBuilder<number>; | ||
option: <T = string>(defaults?: Partial<IOptionalFlag<T>> | Partial<IRequiredFlag<T>> | Partial<IMultiOptionFlag<T>>) => FlagBuilder<T>; | ||
string: FlagBuilder<string>; | ||
}; | ||
export declare function boolean(options?: Partial<IBooleanFlag>): IBooleanFlag; | ||
export declare const integer: Definition<number>; | ||
declare const stringFlag: Definition<string>; | ||
export { stringFlag as string }; | ||
export declare const defaultFlags: { | ||
color: IBooleanFlag; | ||
}; | ||
export declare type Input = { | ||
[name: string]: IFlag<any>; | ||
}; |
@@ -9,18 +9,18 @@ "use strict"; | ||
} | ||
exports.flags = { | ||
boolean: (options = {}) => { | ||
return Object.assign({}, options, { allowNo: !!options.allowNo, type: 'boolean' }); | ||
exports.option = option; | ||
function boolean(options = {}) { | ||
return Object.assign({}, options, { allowNo: !!options.allowNo, type: 'boolean' }); | ||
} | ||
exports.boolean = boolean; | ||
exports.integer = option({ | ||
parse: input => { | ||
if (!/^[0-9]+$/.test(input)) | ||
throw new Error(`Expected an integer but received: ${input}`); | ||
return parseInt(input, 10); | ||
}, | ||
integer: option({ | ||
parse: input => { | ||
if (!/^[0-9]+$/.test(input)) | ||
throw new Error(`Expected an integer but received: ${input}`); | ||
return parseInt(input, 10); | ||
}, | ||
}), | ||
option, | ||
string: option(), | ||
}; | ||
}); | ||
const stringFlag = option(); | ||
exports.string = stringFlag; | ||
exports.defaultFlags = { | ||
color: exports.flags.boolean({ allowNo: true }), | ||
color: boolean({ allowNo: true }), | ||
}; |
@@ -1,18 +0,14 @@ | ||
export { IArg } from './args'; | ||
export { ParserOutput, OutputArgs, OutputFlags } from './parse'; | ||
export { flags, IFlag, IBooleanFlag, IRequiredFlag, IOptionalFlag, IOptionFlag, IMultiOptionFlag, FlagBuilder } from './flags'; | ||
import * as args from './args'; | ||
export { args }; | ||
import * as flags from './flags'; | ||
export { flags }; | ||
export { flagUsages } from './help'; | ||
import { IArg } from './args'; | ||
import { IFlag } from './flags'; | ||
import { ParserOutput } from './parse'; | ||
export declare type InputArgs = IArg<any>[]; | ||
export declare type InputFlags = { | ||
[name: string]: IFlag<any>; | ||
}; | ||
export declare type ParserInput = { | ||
argv?: string[]; | ||
flags?: InputFlags; | ||
args?: InputArgs; | ||
flags?: flags.Input; | ||
args?: args.Input; | ||
strict?: boolean; | ||
}; | ||
export declare function parse(options: ParserInput): ParserOutput; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var flags_1 = require("./flags"); | ||
exports.flags = flags_1.flags; | ||
const args = require("./args"); | ||
exports.args = args; | ||
const flags = require("./flags"); | ||
exports.flags = flags; | ||
var help_1 = require("./help"); | ||
@@ -6,0 +8,0 @@ exports.flagUsages = help_1.flagUsages; |
import { Arg } from './args'; | ||
import { InputFlags } from '.'; | ||
import * as Flags from './flags'; | ||
export declare type OutputArgs = { | ||
@@ -29,3 +29,3 @@ [k: string]: any; | ||
argv: string[]; | ||
flags: InputFlags; | ||
flags: Flags.Input; | ||
args: Arg<any>[]; | ||
@@ -32,0 +32,0 @@ strict: boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ts_lodash_1 = require("ts-lodash"); | ||
const debug = require('debug')('cli-flags'); | ||
let debug; | ||
try { | ||
debug = require('debug')('cli-flags'); | ||
} | ||
catch (err) { | ||
debug = () => { }; | ||
} | ||
class Parser { | ||
@@ -6,0 +12,0 @@ constructor(input) { |
{ | ||
"name": "cli-flags", | ||
"description": "basic CLI flag parser", | ||
"version": "1.0.19", | ||
"version": "2.0.0", | ||
"author": "Jeff Dickey", | ||
@@ -9,5 +9,4 @@ "bugs": "https://github.com/heroku/cli-flags/issues", | ||
"chalk": "^2.3.0", | ||
"cli-ux": "^2.0.8", | ||
"lodash": "^4.17.4", | ||
"ts-lodash": "^4.0.6" | ||
"cli-ux": "^2.0.9", | ||
"ts-lodash": "^4.0.7" | ||
}, | ||
@@ -22,7 +21,7 @@ "devDependencies": { | ||
"husky": "^0.14.3", | ||
"jest": "^21.2.1", | ||
"jest": "^22.0.3", | ||
"lint-staged": "^6.0.0", | ||
"prettier": "^1.9.2", | ||
"remap-istanbul": "^0.9.5", | ||
"ts-jest": "^21.2.4", | ||
"ts-jest": "^22.0.0", | ||
"ts-node": "^4.0.2", | ||
@@ -29,0 +28,0 @@ "tslint": "^5.8.0", |
3
20997
567
- Removedlodash@^4.17.4
Updatedcli-ux@^2.0.9
Updatedts-lodash@^4.0.7