forked from mattallty/Caporal.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
81 lines (58 loc) · 2.08 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
declare class Caporal {
INTEGER: number;
INT: number;
FLOAT: number;
BOOL: number;
BOOLEAN: number;
STRING: number;
LIST: number;
ARRAY: number;
REPEATABLE: number;
REQUIRED: number;
version(ver: string): Caporal;
version(): string;
name(name: string): Caporal;
name(): string;
description(name: string): Caporal;
description(): string;
logger(logger: Logger): Caporal;
logger(): Logger;
bin(name: string): Caporal;
bin(): string;
help(helpText: string, helpOptions?: helpOptions): Caporal;
command(synospis: string, description: string): Command;
action(cb: ActionCallback): Caporal;
option(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any, required?: boolean): Caporal;
argument(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any): Command;
parse(argv: string[]): any;
}
type helpOptions = {
indent?: boolean,
name?: string
};
type ActionCallback = (args: { [k: string]: any },
options: { [k: string]: any },
logger: Logger) => void;
type ValidatorArg = string[]|string|RegExp|ValidatorFn|Number;
type ValidatorFn = (str: string) => any;
declare interface Logger {
debug(str: string): void;
info(str: string): void;
log(str: string): void;
warn(str: string): void;
error(str: string): void;
}
declare interface Command {
help(helpText: string, helpOptions?: helpOptions): Command;
argument(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any): Command;
command(synospis: string, description: string): Command;
option(synopsis: string, description: string, validator?: ValidatorArg, defaultValue?: any, required?: boolean): Command;
action(cb: ActionCallback): Command;
alias(alias: string): Command;
complete(cb: AutocompleteCallback): Command;
}
type AutocompleteCallback = () => string[] | Promise<string[]>;
declare module 'caporal' {
const _default: Caporal;
export default _default;
}