UNPKG

1.86 kBTypeScriptView Raw
1import * as Parser from '@anycli/parser';
2import * as Config from '.';
3export interface Command {
4 id: string;
5 hidden: boolean;
6 aliases: string[];
7 description?: string;
8 title?: string;
9 usage?: string | string[];
10 examples?: string[];
11 type?: string;
12 flags: {
13 [name: string]: Command.Flag;
14 };
15 args: {
16 name: string;
17 description?: string;
18 required?: boolean;
19 hidden?: boolean;
20 default?: string;
21 options?: string[];
22 }[];
23}
24export declare namespace Command {
25 type Flag = Flag.Boolean | Flag.Option;
26 namespace Flag {
27 interface Boolean {
28 type: 'boolean';
29 name: string;
30 required?: boolean;
31 char?: string;
32 hidden?: boolean;
33 description?: string;
34 }
35 interface Option {
36 type: 'option';
37 name: string;
38 required?: boolean;
39 char?: string;
40 hidden?: boolean;
41 description?: string;
42 helpValue?: string;
43 default?: string;
44 options?: string[];
45 }
46 }
47 interface Base {
48 _base: string;
49 id: string;
50 hidden: boolean;
51 aliases: string[];
52 description?: string;
53 title?: string;
54 usage?: string | string[];
55 examples?: string[];
56 }
57 interface Class extends Base {
58 plugin?: Config.IPlugin;
59 flags?: Parser.flags.Input<any>;
60 args?: Parser.args.Input;
61 new (argv: string[], config?: Config.Options): Instance;
62 run(argv: string[], config?: Config.Options): Promise<any>;
63 }
64 interface Instance {
65 _run(argv: string[]): Promise<any>;
66 }
67 interface Plugin extends Command {
68 load(): Class;
69 }
70 function toCached(c: Class): Command;
71}