UNPKG

1.83 kBTypeScriptView Raw
1import * as Config from '@anycli/config';
2import * as Parser from '@anycli/parser';
3import * as flags from './flags';
4export default abstract class Command {
5 argv: string[];
6 static _base: string;
7 static id: string;
8 static title: string | undefined;
9 static description: string | undefined;
10 static hidden: boolean;
11 static usage: string | string[] | undefined;
12 static help: string | undefined;
13 static aliases: string[];
14 static strict: boolean;
15 static parse: boolean;
16 static flags: flags.Input<any>;
17 static args: Parser.args.IArg[];
18 static plugin: Config.IPlugin | undefined;
19 static examples: string[] | undefined;
20 static parserOptions: {};
21 /**
22 * instantiate and run the command
23 */
24 static run: Config.Command.Class['run'];
25 description: null;
26 hidden: null;
27 usage: null;
28 aliases: null;
29 title: null;
30 strict: null;
31 examples: null;
32 id: string | undefined;
33 config: Config.IConfig;
34 protected debug: (...args: any[]) => void;
35 constructor(argv: string[], options: Config.Options);
36 readonly ctor: typeof Command;
37 _run(): Promise<void>;
38 exit(code?: number): void;
39 warn(input: string | Error): void;
40 error(input: string | Error, options?: {
41 code?: string;
42 exit?: number;
43 }): void;
44 log(message?: any): void;
45 /**
46 * actual command run code goes here
47 */
48 abstract run(): Promise<any>;
49 protected init(): Promise<void>;
50 protected parse<F, A extends {
51 [name: string]: any;
52 }>(options?: Parser.Input<F>, argv?: string[]): Parser.Output<F, A>;
53 protected catch(err: any): Promise<void>;
54 protected finally(_: Error | undefined): Promise<void>;
55 protected _help(): void;
56 protected _helpOverride(): boolean;
57 protected _version(): void;
58}