|
| 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): Caporal; |
| 29 | + |
| 30 | + command(synospis: 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 | +} |
| 40 | + |
| 41 | +type ActionCallback = (args: { [k: string]: any }, |
| 42 | + options: { [k: string]: any }, |
| 43 | + logger: Logger) => void; |
| 44 | + |
| 45 | +type ValidatorArg = string[]|string|RegExp|ValidatorFn|Number; |
| 46 | +type ValidatorFn = (str: string) => any; |
| 47 | + |
| 48 | +declare interface Logger { |
| 49 | + debug(str: string): void; |
| 50 | + info(str: string): void; |
| 51 | + log(str: string): void; |
| 52 | + warn(str: string): void; |
| 53 | + error(str: string): void; |
| 54 | +} |
| 55 | + |
| 56 | +declare interface Command { |
| 57 | + help(helpText: string): Command; |
| 58 | + |
| 59 | + argument(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any): Command; |
| 60 | + |
| 61 | + command(synospis: string, description: string): Command; |
| 62 | + |
| 63 | + option(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any, required?: boolean): Command; |
| 64 | + |
| 65 | + action(cb: ActionCallback): Command; |
| 66 | + |
| 67 | + alias(alias: string): Command; |
| 68 | + |
| 69 | + complete(cb: AutocompleteCallback): Command; |
| 70 | +} |
| 71 | + |
| 72 | +type AutocompleteCallback = () => string[] | Promise<string[]>; |
| 73 | + |
| 74 | +export = new Caporal(); |
0 commit comments