UNPKG

1.25 kBTypeScriptView Raw
1/// <reference types="node" />
2import { EventEmitter } from 'events';
3import Command, { HelpCallback, CommandExample } from './Command';
4import { OptionConfig } from './Option';
5interface ParsedArgv {
6 args: string[];
7 options: {
8 [k: string]: any;
9 };
10}
11declare class CAC extends EventEmitter {
12 bin: string;
13 commands: Command[];
14 globalCommand: Command;
15 matchedCommand: Command;
16 /**
17 * Raw CLI arguments
18 */
19 rawArgs: string[];
20 /**
21 * Parsed CLI arguments
22 */
23 args: string[];
24 /**
25 * Parsed CLI options, camelCased
26 */
27 options: {
28 [k: string]: any;
29 };
30 constructor();
31 usage(text: string): this;
32 command(rawName: string, description: string): Command;
33 option(rawName: string, description: string, config?: OptionConfig): this;
34 help(callback?: HelpCallback): this;
35 version(version: string, customFlags?: string): this;
36 /**
37 * Add a global example
38 * @param example
39 */
40 example(example: CommandExample): this;
41 outputHelp(subCommand?: boolean): this;
42 outputVersion(): this;
43 parse(argv?: string[]): ParsedArgv;
44 private minimist;
45 private runCommandAction;
46}
47declare const cac: () => CAC;
48export = cac;