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