From f7e6a82c10f423a118c4e0b5d1af33b20a6191dc Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Wed, 27 May 2020 10:59:30 +0600 Subject: [PATCH] refactor: cleanup flags --- src/flags.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/flags.ts b/src/flags.ts index d6089a57..0d7e2c39 100644 --- a/src/flags.ts +++ b/src/flags.ts @@ -24,7 +24,7 @@ export type IOptionFlag = Parser.flags.IOptionFlag & { export type IFlag = Parser.flags.IBooleanFlag | IOptionFlag export type Output = Parser.flags.Output -export type Input = { [P in keyof T]: IFlag } +export type Input = { [P in keyof T]: IFlag } export type Definition = { (options: {multiple: true} & Partial>): IOptionFlag; @@ -44,13 +44,12 @@ export function option(options: {parse: IOptionFlag['parse']} & Partial(opts: Parser.flags.EnumFlagOptions): IOptionFlag => { return build({ - parse(input) { + parse(input, _) { if (!opts.options.includes(input)) throw new Error(`Expected --${this.name}=${input} to be one of: ${opts.options.join(', ')}`) - return input + return input as unknown as T }, helpValue: `(${opts.options.join('|')})`, - ...opts as any, - optionType: 'enum', + ...opts, })() as IOptionFlag } export {_enum as enum} @@ -70,6 +69,7 @@ export const version = (opts: Partial> = {}) }, }) } + export const help = (opts: Partial> = {}) => { return Parser.flags.boolean({ // char: 'h',