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 Default<T> = T | ((context: DefaultContext<T>) => T);
|
9 | export declare type IFlagBase<T, I> = {
|
10 | name: string;
|
11 | char?: AlphabetLowercase | AlphabetUppercase;
|
12 | description?: string;
|
13 | helpLabel?: string;
|
14 | hidden?: boolean;
|
15 | required?: boolean;
|
16 | dependsOn?: string[];
|
17 | exclusive?: string[];
|
18 | exactlyOne?: string[];
|
19 | /**
|
20 | * also accept an environment variable as input
|
21 | */
|
22 | env?: string;
|
23 | parse(input: I, context: any): T;
|
24 | };
|
25 | export declare type IBooleanFlag<T> = IFlagBase<T, boolean> & {
|
26 | type: 'boolean';
|
27 | allowNo: boolean;
|
28 | /**
|
29 | * specifying a default of false is the same not specifying a default
|
30 | */
|
31 | default?: Default<boolean>;
|
32 | };
|
33 | export declare type IOptionFlag<T> = IFlagBase<T, string> & {
|
34 | type: 'option';
|
35 | helpValue?: string;
|
36 | default?: Default<T | undefined>;
|
37 | multiple: boolean;
|
38 | input: string[];
|
39 | options?: string[];
|
40 | };
|
41 | export declare type Definition<T> = {
|
42 | (options: {
|
43 | multiple: true;
|
44 | } & Partial<IOptionFlag<T[]>>): IOptionFlag<T[]>;
|
45 | (options: ({
|
46 | required: true;
|
47 | } | {
|
48 | default: Default<T>;
|
49 | }) & Partial<IOptionFlag<T>>): IOptionFlag<T>;
|
50 | (options?: Partial<IOptionFlag<T>>): IOptionFlag<T | undefined>;
|
51 | };
|
52 | export declare type EnumFlagOptions<T> = Partial<IOptionFlag<T>> & {
|
53 | options: T[];
|
54 | };
|
55 | export declare type IFlag<T> = IBooleanFlag<T> | IOptionFlag<T>;
|
56 | export declare function build<T>(defaults: {
|
57 | parse: IOptionFlag<T>['parse'];
|
58 | } & Partial<IOptionFlag<T>>): Definition<T>;
|
59 | export declare function build(defaults: Partial<IOptionFlag<string>>): Definition<string>;
|
60 | export declare function boolean<T = boolean>(options?: Partial<IBooleanFlag<T>>): IBooleanFlag<T>;
|
61 | export declare const integer: Definition<number>;
|
62 | export declare function option<T>(options: {
|
63 | parse: IOptionFlag<T>['parse'];
|
64 | } & Partial<IOptionFlag<T>>): IOptionFlag<T | undefined>;
|
65 | declare const stringFlag: Definition<string>;
|
66 | export { stringFlag as string };
|
67 | export declare const defaultFlags: {
|
68 | color: IBooleanFlag<boolean>;
|
69 | };
|
70 | export declare type Output = {
|
71 | [name: string]: any;
|
72 | };
|
73 | export declare type Input<T extends Output> = {
|
74 | [P in keyof T]: IFlag<T[P]>;
|
75 | };
|
76 |
|
\ | No newline at end of file |