UNPKG

4.35 kBTypeScriptView Raw
1import { ParsedOptions } from 'getopts';
2import { Prompt, FakePrompt } from '@poppinss/prompts';
3import { instantiate } from '@poppinss/cliui/build/api';
4import { ApplicationContract } from '@ioc:Adonis/Core/Application';
5import { CommandArg, CommandFlag, KernelContract, CommandSettings, CommandContract, GeneratorContract } from '../Contracts';
6/**
7 * Abstract base class other classes must extend
8 */
9export declare abstract class BaseCommand implements CommandContract {
10 application: ApplicationContract;
11 kernel: KernelContract;
12 /**
13 * Reference to the exit handler
14 */
15 protected exitHandler?: () => void | Promise<void>;
16 /**
17 * Accepting AdonisJs application instance and kernel instance
18 */
19 constructor(application: ApplicationContract, kernel: KernelContract);
20 /**
21 * Command arguments
22 */
23 static args: CommandArg[];
24 /**
25 * Command aliases
26 */
27 static aliases: string[];
28 /**
29 * Command flags
30 */
31 static flags: CommandFlag[];
32 /**
33 * Command name. The command will be registered using this name only. Make
34 * sure their aren't any spaces inside the command name.
35 */
36 static commandName: string;
37 /**
38 * The description of the command displayed on the help screen.
39 * A good command will always have some description.
40 */
41 static description: string;
42 /**
43 * Any settings a command wants to have. Helpful for third party
44 * tools to read the settings in lifecycle hooks and make
45 * certain decisions
46 */
47 static settings: CommandSettings;
48 /**
49 * Whether or not the command has been booted
50 */
51 static booted: boolean;
52 /**
53 * Boots the command by defining required static properties
54 */
55 static boot(): void;
56 /**
57 * Define an argument directly on the command without using the decorator
58 */
59 static $addArgument(options: Partial<CommandArg>): void;
60 /**
61 * Define a flag directly on the command without using the decorator
62 */
63 static $addFlag(options: Partial<CommandFlag>): void;
64 /**
65 * Reference to cli ui
66 */
67 ui: {
68 table: () => import("@poppinss/cliui/build/src/Table").Table;
69 tasks: {
70 (): import("@poppinss/cliui/build/src/Task/Manager").TaskManager;
71 verbose(): import("@poppinss/cliui/build/src/Task/Manager").TaskManager;
72 };
73 icons: {
74 tick: string;
75 cross: string;
76 bullet: string;
77 nodejs: string;
78 pointer: string;
79 info: string;
80 warning: string;
81 squareSmallFilled: string;
82 };
83 logger: import("@poppinss/cliui/build/src/Logger").Logger;
84 sticker: () => import("@poppinss/cliui/build/src/Instructions").Instructions;
85 instructions: () => import("@poppinss/cliui/build/src/Instructions").Instructions;
86 isInteractive: boolean;
87 supportsColors: boolean;
88 consoleRenderer: import("@poppinss/cliui/build/src/Renderer/Console").ConsoleRenderer;
89 testingRenderer: import("@poppinss/cliui/build/src/Renderer/Memory").MemoryRenderer;
90 };
91 /**
92 * Parsed options on the command. They only exist when the command
93 * is executed via kernel.
94 */
95 parsed?: ParsedOptions;
96 /**
97 * The prompt for the command
98 */
99 prompt: Prompt | FakePrompt;
100 /**
101 * Returns the instance of logger to log messages
102 */
103 logger: import("@poppinss/cliui/build/src/Logger").Logger;
104 /**
105 * Reference to the colors
106 */
107 colors: ReturnType<typeof instantiate>['logger']['colors'];
108 /**
109 * Generator instance to generate entity files
110 */
111 generator: GeneratorContract;
112 /**
113 * Error raised by the command
114 */
115 error?: any;
116 /**
117 * Command exit code
118 */
119 exitCode?: number;
120 run?(...args: any[]): Promise<any>;
121 prepare?(...args: any[]): Promise<any>;
122 completed?(...args: any[]): Promise<any>;
123 /**
124 * Execute the command
125 */
126 exec(): Promise<any>;
127 /**
128 * Register an onExit handler
129 */
130 onExit(handler: () => void | Promise<void>): this;
131 /**
132 * Trigger exit
133 */
134 exit(): Promise<void>;
135 /**
136 * Must be defined by the parent class
137 */
138 handle?(...args: any[]): Promise<any>;
139}