1 | declare class Caporal {
|
2 | INTEGER: number;
|
3 | INT: number;
|
4 | FLOAT: number;
|
5 | BOOL: number;
|
6 | BOOLEAN: number;
|
7 | STRING: number;
|
8 | LIST: number;
|
9 | ARRAY: number;
|
10 | REPEATABLE: number;
|
11 | REQUIRED: number;
|
12 |
|
13 | version(ver: string): Caporal;
|
14 | version(): string;
|
15 |
|
16 | name(name: string): Caporal;
|
17 | name(): string;
|
18 |
|
19 | description(name: string): Caporal;
|
20 | description(): string;
|
21 |
|
22 | logger(logger: Logger): Caporal;
|
23 | logger(): Logger;
|
24 |
|
25 | bin(name: string): Caporal;
|
26 | bin(): string;
|
27 |
|
28 | help(helpText: string, helpOptions?: helpOptions): Caporal;
|
29 |
|
30 | command(synopsis: string, description: string): Command;
|
31 |
|
32 | action(cb: ActionCallback): Caporal;
|
33 |
|
34 | option(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any, required?: boolean): Caporal;
|
35 |
|
36 | argument(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any): Command;
|
37 |
|
38 | parse(argv: string[]): any;
|
39 | fatalError(error: Error): void;
|
40 | }
|
41 |
|
42 | type helpOptions = {
|
43 | indent?: boolean,
|
44 | name?: string
|
45 | };
|
46 |
|
47 | type ActionCallback = (args: { [k: string]: any },
|
48 | options: { [k: string]: any },
|
49 | logger: Logger) => void;
|
50 |
|
51 | type ValidatorArg = string[]|string|RegExp|ValidatorFn|Number;
|
52 | type ValidatorFn = (str: string) => any;
|
53 |
|
54 | declare interface Logger {
|
55 | debug(str: string|object): void;
|
56 | debug(format: string, ...mixed: any[]): void;
|
57 | info(str: string|object): void;
|
58 | info(format: string, ...mixed: any[]): void;
|
59 | log(str: string|object): void;
|
60 | log(format: string, ...mixed: any[]): void;
|
61 | warn(str: string|object): void;
|
62 | warn(format: string, ...mixed: any[]): void;
|
63 | error(str: string|object): void;
|
64 | error(format: string, ...mixed: any[]): void;
|
65 | }
|
66 |
|
67 | declare interface Command {
|
68 | help(helpText: string, helpOptions?: helpOptions): Command;
|
69 |
|
70 | argument(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any): Command;
|
71 |
|
72 | command(synospis: string, description: string): Command;
|
73 |
|
74 | option(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any, required?: boolean): Command;
|
75 |
|
76 | action(cb: ActionCallback): Command;
|
77 |
|
78 | alias(alias: string): Command;
|
79 |
|
80 | complete(cb: AutocompleteCallback): Command;
|
81 |
|
82 | visible(): boolean;
|
83 | visibile(visibility: boolean): Command;
|
84 | }
|
85 |
|
86 | type AutocompleteCallback = () => string[] | Promise<string[]>;
|
87 | declare module 'caporal' {
|
88 | const caporal: Caporal;
|
89 | export = caporal;
|
90 | }
|