UNPKG

cmd-ts

Version:

> 💻 A type-driven command line argument parser, with awesome error reporting 🤤

26 lines (25 loc) • 1.6 kB
import { ArgParser, Register } from './argparser'; import { ProvidesHelp, Descriptive, ShortDoc, LongDoc, EnvDoc } from './helpdoc'; import { Type, OutputOf, HasType } from './type'; import { Default } from './default'; import { AllOrNothing } from './utils'; declare type FlagConfig<Decoder extends Type<boolean, any>> = LongDoc & HasType<Decoder> & Partial<ShortDoc & Descriptive & EnvDoc> & AllOrNothing<Default<OutputOf<Decoder>>>; /** * A decoder from `string` to `boolean` * works for `true` and `false` only. */ export declare const boolean: Type<string, boolean>; export declare function fullFlag<Decoder extends Type<boolean, any>>(config: FlagConfig<Decoder>): ArgParser<OutputOf<Decoder>> & ProvidesHelp & Register & Partial<Descriptive>; declare type BooleanType = Type<boolean, boolean>; /** * Decodes an argument which is in the form of a key and a boolean value, and allows parsing the following ways: * * - `--long` where `long` is the provided `long` * - `-s=value` where `s` is the provided `short` * Shorthand forms can be combined: * - `-abcd` will call all flags for the short forms of `a`, `b`, `c` and `d`. * @param config flag configurations */ export declare function flag<Decoder extends Type<boolean, any>>(config: FlagConfig<Decoder>): ArgParser<OutputOf<Decoder>> & ProvidesHelp & Register & Partial<Descriptive>; export declare function flag(config: LongDoc & Partial<HasType<never> & ShortDoc & Descriptive & EnvDoc> & AllOrNothing<Default<OutputOf<BooleanType>>>): ArgParser<OutputOf<BooleanType>> & ProvidesHelp & Register & Partial<Descriptive>; export {};