commander 2.12.1 → 2.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ 2.12.2 / 2017-11-28
3
+ ==================
4
+
5
+ * fix: typings are not shipped
6
+
2
7
  2.12.1 / 2017-11-23
3
8
  ==================
4
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commander",
3
- "version": "2.12.1",
3
+ "version": "2.12.2",
4
4
  "description": "the complete solution for node.js command-line programs",
5
5
  "keywords": [
6
6
  "commander",
@@ -20,14 +20,15 @@
20
20
  },
21
21
  "main": "index",
22
22
  "files": [
23
- "index.js"
23
+ "index.js",
24
+ "typings/index.d.ts"
24
25
  ],
25
26
  "dependencies": {},
26
27
  "devDependencies": {
27
28
  "@types/node": "^7.0.48",
28
29
  "should": "^11.2.1",
29
30
  "sinon": "^2.4.1",
30
- "typescript": "^2.6.1"
31
+ "typescript": "^2.6.2"
31
32
  },
32
33
  "typings": "typings/index.d.ts"
33
34
  }
@@ -0,0 +1,295 @@
1
+ // Project: https://github.com/visionmedia/commander.js
2
+ // Definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>
3
+
4
+ declare class Option {
5
+ flags: string;
6
+ required: boolean;
7
+ optional: boolean;
8
+ bool: boolean;
9
+ short?: string;
10
+ long: string;
11
+ description: string;
12
+
13
+ /**
14
+ * Initialize a new `Option` with the given `flags` and `description`.
15
+ *
16
+ * @param {string} flags
17
+ * @param {string} [description]
18
+ */
19
+ constructor(flags: string, description?: string);
20
+ }
21
+
22
+ declare class Command extends NodeJS.EventEmitter {
23
+ [key: string]: any;
24
+
25
+ args: string[];
26
+
27
+ /**
28
+ * Initialize a new `Command`.
29
+ *
30
+ * @param {string} [name]
31
+ */
32
+ constructor(name?: string);
33
+
34
+ /**
35
+ * Set the program version to `str`.
36
+ *
37
+ * This method auto-registers the "-V, --version" flag
38
+ * which will print the version number when passed.
39
+ *
40
+ * @param {string} str
41
+ * @param {string} [flags]
42
+ * @returns {Command} for chaining
43
+ */
44
+ version(str: string, flags?: string): Command;
45
+
46
+ /**
47
+ * Add command `name`.
48
+ *
49
+ * The `.action()` callback is invoked when the
50
+ * command `name` is specified via __ARGV__,
51
+ * and the remaining arguments are applied to the
52
+ * function for access.
53
+ *
54
+ * When the `name` is "*" an un-matched command
55
+ * will be passed as the first arg, followed by
56
+ * the rest of __ARGV__ remaining.
57
+ *
58
+ * @example
59
+ * program
60
+ * .version('0.0.1')
61
+ * .option('-C, --chdir <path>', 'change the working directory')
62
+ * .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
63
+ * .option('-T, --no-tests', 'ignore test hook')
64
+ *
65
+ * program
66
+ * .command('setup')
67
+ * .description('run remote setup commands')
68
+ * .action(function() {
69
+ * console.log('setup');
70
+ * });
71
+ *
72
+ * program
73
+ * .command('exec <cmd>')
74
+ * .description('run the given remote command')
75
+ * .action(function(cmd) {
76
+ * console.log('exec "%s"', cmd);
77
+ * });
78
+ *
79
+ * program
80
+ * .command('teardown <dir> [otherDirs...]')
81
+ * .description('run teardown commands')
82
+ * .action(function(dir, otherDirs) {
83
+ * console.log('dir "%s"', dir);
84
+ * if (otherDirs) {
85
+ * otherDirs.forEach(function (oDir) {
86
+ * console.log('dir "%s"', oDir);
87
+ * });
88
+ * }
89
+ * });
90
+ *
91
+ * program
92
+ * .command('*')
93
+ * .description('deploy the given env')
94
+ * .action(function(env) {
95
+ * console.log('deploying "%s"', env);
96
+ * });
97
+ *
98
+ * program.parse(process.argv);
99
+ *
100
+ * @param {string} name
101
+ * @param {string} [desc] for git-style sub-commands
102
+ * @param {CommandOptions} [opts] command options
103
+ * @returns {Command} the new command
104
+ */
105
+ command(name: string, desc?: string, opts?: commander.CommandOptions): Command;
106
+
107
+ /**
108
+ * Define argument syntax for the top-level command.
109
+ *
110
+ * @param {string} desc
111
+ * @returns {Command} for chaining
112
+ */
113
+ arguments(desc: string): Command;
114
+
115
+ /**
116
+ * Parse expected `args`.
117
+ *
118
+ * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
119
+ *
120
+ * @param {string[]} args
121
+ * @returns {Command} for chaining
122
+ */
123
+ parseExpectedArgs(args: string[]): Command;
124
+ /**
125
+ * Register callback `fn` for the command.
126
+ *
127
+ * @example
128
+ * program
129
+ * .command('help')
130
+ * .description('display verbose help')
131
+ * .action(function() {
132
+ * // output help here
133
+ * });
134
+ *
135
+ * @param {(...args: any[]) => void} fn
136
+ * @returns {Command} for chaining
137
+ */
138
+ action(fn: (...args: any[]) => void): Command;
139
+
140
+ /**
141
+ * Define option with `flags`, `description` and optional
142
+ * coercion `fn`.
143
+ *
144
+ * The `flags` string should contain both the short and long flags,
145
+ * separated by comma, a pipe or space. The following are all valid
146
+ * all will output this way when `--help` is used.
147
+ *
148
+ * "-p, --pepper"
149
+ * "-p|--pepper"
150
+ * "-p --pepper"
151
+ *
152
+ * @example
153
+ * // simple boolean defaulting to false
154
+ * program.option('-p, --pepper', 'add pepper');
155
+ *
156
+ * --pepper
157
+ * program.pepper
158
+ * // => Boolean
159
+ *
160
+ * // simple boolean defaulting to true
161
+ * program.option('-C, --no-cheese', 'remove cheese');
162
+ *
163
+ * program.cheese
164
+ * // => true
165
+ *
166
+ * --no-cheese
167
+ * program.cheese
168
+ * // => false
169
+ *
170
+ * // required argument
171
+ * program.option('-C, --chdir <path>', 'change the working directory');
172
+ *
173
+ * --chdir /tmp
174
+ * program.chdir
175
+ * // => "/tmp"
176
+ *
177
+ * // optional argument
178
+ * program.option('-c, --cheese [type]', 'add cheese [marble]');
179
+ *
180
+ * @param {string} flags
181
+ * @param {string} [description]
182
+ * @param {((arg1: any, arg2: any) => void) | RegExp} [fn] function or default
183
+ * @param {*} [defaultValue]
184
+ * @returns {Command} for chaining
185
+ */
186
+ option(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;
187
+ option(flags: string, description?: string, defaultValue?: any): Command;
188
+
189
+ /**
190
+ * Allow unknown options on the command line.
191
+ *
192
+ * @param {boolean} [arg] if `true` or omitted, no error will be thrown for unknown options.
193
+ * @returns {Command} for chaining
194
+ */
195
+ allowUnknownOption(arg?: boolean): Command;
196
+
197
+ /**
198
+ * Parse `argv`, settings options and invoking commands when defined.
199
+ *
200
+ * @param {string[]} argv
201
+ * @returns {Command} for chaining
202
+ */
203
+ parse(argv: string[]): Command;
204
+
205
+ /**
206
+ * Parse options from `argv` returning `argv` void of these options.
207
+ *
208
+ * @param {string[]} argv
209
+ * @returns {ParseOptionsResult}
210
+ */
211
+ parseOptions(argv: string[]): commander.ParseOptionsResult;
212
+
213
+ /**
214
+ * Return an object containing options as key-value pairs
215
+ *
216
+ * @returns {{[key: string]: string}}
217
+ */
218
+ opts(): { [key: string]: string };
219
+
220
+ /**
221
+ * Set the description to `str`.
222
+ *
223
+ * @param {string} str
224
+ * @return {(Command | string)}
225
+ */
226
+ description(str: string): Command;
227
+ description(): string;
228
+
229
+ /**
230
+ * Set an alias for the command.
231
+ *
232
+ * @param {string} alias
233
+ * @return {(Command | string)}
234
+ */
235
+ alias(alias: string): Command;
236
+ alias(): string;
237
+
238
+ /**
239
+ * Set or get the command usage.
240
+ *
241
+ * @param {string} str
242
+ * @return {(Command | string)}
243
+ */
244
+ usage(str: string): Command;
245
+ usage(): string;
246
+
247
+ /**
248
+ * Set the name of the command.
249
+ *
250
+ * @param {string} str
251
+ * @return {Command}
252
+ */
253
+ name(str: string): Command;
254
+
255
+ /**
256
+ * Get the name of the command.
257
+ *
258
+ * @return {string}
259
+ */
260
+ name(): string;
261
+
262
+ /**
263
+ * Output help information for this command.
264
+ *
265
+ * @param {(str: string) => string} [cb]
266
+ */
267
+ outputHelp(cb?: (str: string) => string): void;
268
+
269
+ /** Output help information and exit. */
270
+ help(): void;
271
+ }
272
+
273
+ declare namespace commander {
274
+
275
+ interface CommandOptions {
276
+ noHelp?: boolean;
277
+ isDefault?: boolean;
278
+ }
279
+
280
+ interface ParseOptionsResult {
281
+ args: string[];
282
+ unknown: string[];
283
+ }
284
+
285
+ interface CommanderStatic extends Command {
286
+ Command: typeof Command;
287
+ Option: typeof Option;
288
+ CommandOptions: CommandOptions;
289
+ ParseOptionsResult: ParseOptionsResult;
290
+ }
291
+
292
+ }
293
+
294
+ declare const commander: commander.CommanderStatic;
295
+ export = commander;