forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nomnom.d.ts
231 lines (197 loc) · 6.08 KB
/
nomnom.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// Type definitions for nomnom
// Project: https://github.com/harthur/nomnom
// Definitions by: Paul Vick <https://github.com/panopticoncentral>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// NOTE: Extra identifier's been published is a work-around for the TypeScript 1.0.0.
// original is here -> https://github.com/borisyankov/DefinitelyTyped/commit/9aef1ad84dc006e3d25f5e57709198e33996ba84#diff-0d78c90325d4bfb40327dcc36dcd939a
declare module NomnomInternal
{
/**
* The command-line parser.
*/
module Parser
{
/**
* A command-line option.
*/
export interface Option
{
/**
* The abbreviated name of the option.
*/
abbr?: string;
/**
* The full name of the option.
*/
full?: string;
/**
* Whether the option is a flag.
*/
flag?: boolean;
/**
* A string to be used in the usage printout.
*/
metavar?: string;
/**
* A shorthand for abbr, full, and metavar.
*/
string?: string;
/**
* A help string for the option.
*/
help?: string;
/**
* The default value of the option.
*/
default?: any;
/**
* A callback for the option.
*/
callback?: (option: any) => string;
/**
* The position of the option if it's a positional argument.
*/
position?: number;
/**
* Whether the option is a list.
*/
list?: boolean;
/**
* Whether the option is required.
*/
required?: boolean;
/**
* The choices for the option.
*/
choices?: string[];
/**
* If you don't want the option JSON-parsed, specify type "string".
*/
type?: string;
/**
* Whether the option is hidden.
*/
hidden?: boolean;
}
/**
* A command-line command specification.
*/
export interface Command
{
/**
* The name of the command.
*/
name: string;
/**
* Sets the options of the command.
* @param specs The specifications of the options.
* @returns The command.
*/
options(specs: { [index: string]: Option }): Command;
/**
* Sets an option of the command.
* @param name The name of the option.
* @param spec The specifiction of the option.
* @returns The command.
*/
option(name: string, spec: Option): Command;
/**
* Sets a callback for the command.
* @param func The callback function.
* @returns The command.
*/
callback(func: (options: any) => void): Command;
/**
* Sets the help string for the command.
* @param help The help string.
* @returns The command.
*/
help(help: string): Command;
/**
* Sets the usage string for the command.
* @param usage The usage string.
* @returns The command.
*/
usage(usage: string): Command;
}
}
/**
* The command-line parser.
*/
export interface Parser
{
/**
* Returns the parser.
*/
(): Parser;
/**
* Creates a new command.
* @param name The name of the command.
* @returns The new command.
*/
command(name: string): Parser.Command;
/**
* Returns the commmand representing no command.
* @returns The command representing no command.
*/
nocommand(): Parser.Command;
/**
* Sets the options of the command-line.
* @param specs The specifications of the options.
* @returns The command-line parser.
*/
options(specs: { [index: string]: Parser.Option }): Parser;
/**
* Sets an option of the command-line.
* @param name The name of the option.
* @param spec The specifiction of the option.
* @returns The command-line parser.
*/
option(name: string, spec: Parser.Option): Parser;
/**
* Sets the usage string for the command-line.
* @param usage The usage string.
* @returns The command-line parser.
*/
usage(usage: string): Parser;
/**
* Provides a printer to the command-line processor.
* @param print The print function to use.
* @returns The command-line parser.
*/
printer(print: (message: string, code?: number) => void): Parser;
/**
* Sets the name of the script.
* @param script The script name.
* @returns The command-line parser.
*/
script(script: string): Parser;
/**
* Sets the help string for the command-line.
* @param help The help string.
* @returns The command-line parser.
*/
help(help: string): Parser;
/**
* Sets the command-line parser not to use colors.
* @returns The command-line parser.
*/
nocolors(): Parser;
/**
* Parses the command-line.
* @param argv The command-line arguments.
* @returns The parsed command-line.
*/
nom(argv?: string[]): any;
/**
* Parses the command-line.
* @param argv The command-line arguments.
* @returns The parsed command-line.
*/
parse(argv?: string[]): any;
}
}
declare var _nomnom: NomnomInternal.Parser;
declare module "nomnom" {
export = _nomnom;
}