1 | import { AlphabetLowercase, AlphabetUppercase } from './alphabet';
|
2 | export declare type DefaultContext<T> = {
|
3 | options: IOptionFlag<T>;
|
4 | flags: {
|
5 | [k: string]: string;
|
6 | };
|
7 | };
|
8 | export declare type IFlagBase<T, I> = {
|
9 | name: string;
|
10 | char?: AlphabetLowercase | AlphabetUppercase;
|
11 | description?: string;
|
12 | hidden?: boolean;
|
13 | required?: boolean;
|
14 | alsoRequire?: string[];
|
15 | |
16 |
|
17 |
|
18 | env?: string;
|
19 | parse(input: I, context: any): T;
|
20 | };
|
21 | export declare type IBooleanFlag<T> = IFlagBase<T, boolean> & {
|
22 | type: 'boolean';
|
23 | allowNo: boolean;
|
24 | };
|
25 | export declare type IOptionFlag<T> = IFlagBase<T, string> & {
|
26 | type: 'option';
|
27 | helpValue?: string;
|
28 | default?: T | ((context: DefaultContext<T>) => T | undefined);
|
29 | multiple: boolean;
|
30 | input: string[];
|
31 | options?: string[];
|
32 | };
|
33 | export declare type Definition<T> = {
|
34 | (options: {
|
35 | multiple: true;
|
36 | } & Partial<IOptionFlag<T>>): IOptionFlag<T[]>;
|
37 | (options: {
|
38 | required: true;
|
39 | } & Partial<IOptionFlag<T>>): IOptionFlag<T>;
|
40 | (options?: Partial<IOptionFlag<T>>): IOptionFlag<T | undefined>;
|
41 | };
|
42 | export declare type EnumFlagOptions<T> = Partial<IOptionFlag<T>> & {
|
43 | options: string[];
|
44 | };
|
45 | export declare type IFlag<T> = IBooleanFlag<T> | IOptionFlag<T>;
|
46 | export declare function build<T>(defaults: {
|
47 | parse: IOptionFlag<T>['parse'];
|
48 | } & Partial<IOptionFlag<T>>): Definition<T>;
|
49 | export declare function build(defaults: Partial<IOptionFlag<string>>): Definition<string>;
|
50 | export declare function boolean<T = boolean>(options?: Partial<IBooleanFlag<T>>): IBooleanFlag<T>;
|
51 | export declare const integer: Definition<number>;
|
52 | export declare function option<T>(options: {
|
53 | parse: IOptionFlag<T>['parse'];
|
54 | } & Partial<IOptionFlag<T>>): IOptionFlag<T | undefined>;
|
55 | declare const stringFlag: Definition<string>;
|
56 | export { stringFlag as string };
|
57 | export declare const defaultFlags: {
|
58 | color: IBooleanFlag<boolean>;
|
59 | };
|
60 | export declare type Output = {
|
61 | [name: string]: any;
|
62 | };
|
63 | export declare type Input<T extends Output> = {
|
64 | [P in keyof T]: IFlag<T[P]>;
|
65 | };
|
66 |
|
\ | No newline at end of file |