1 | import { ApplicationContract } from '@ioc:Adonis/Core/Application';
|
2 | import { ManifestLoader } from '../Manifest/Loader';
|
3 | import { CommandFlag, KernelContract, CommandContract, ManifestCommand, RunHookCallback, FindHookCallback, GlobalFlagHandler, CommandConstructorContract } from '../Contracts';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export declare class Kernel implements KernelContract {
|
9 | application: ApplicationContract;
|
10 | |
11 |
|
12 |
|
13 |
|
14 | private hooks;
|
15 | |
16 |
|
17 |
|
18 |
|
19 | private manifestLoader;
|
20 | |
21 |
|
22 |
|
23 | private entryCommand?;
|
24 | |
25 |
|
26 |
|
27 | private state;
|
28 | |
29 |
|
30 |
|
31 | private exitHandler;
|
32 | |
33 |
|
34 |
|
35 |
|
36 | isInteractive: boolean;
|
37 | |
38 |
|
39 |
|
40 | isMockingConsoleOutput: boolean;
|
41 | |
42 |
|
43 |
|
44 |
|
45 | defaultCommand: CommandConstructorContract;
|
46 | |
47 |
|
48 |
|
49 | commands: {
|
50 | [name: string]: CommandConstructorContract;
|
51 | };
|
52 | aliases: {
|
53 | [alias: string]: string;
|
54 | };
|
55 | |
56 |
|
57 |
|
58 | flags: {
|
59 | [name: string]: CommandFlag & {
|
60 | handler: GlobalFlagHandler;
|
61 | };
|
62 | };
|
63 | |
64 |
|
65 |
|
66 | exitCode?: number;
|
67 | |
68 |
|
69 |
|
70 |
|
71 | error?: any;
|
72 | constructor(application: ApplicationContract);
|
73 | /**
|
74 | * Executing global flag handlers. The global flag handlers are
|
75 | * not async as of now, but later we can look into making them
|
76 | * async.
|
77 | */
|
78 | private executeGlobalFlagsHandlers;
|
79 | /**
|
80 | * Returns an array of all registered commands
|
81 | */
|
82 | private getAllCommandsAndAliases;
|
83 | /**
|
84 | * Processes the args and sets values on the command instance
|
85 | */
|
86 | private processCommandArgsAndFlags;
|
87 | /**
|
88 | * Execute the main command. For calling commands within commands,
|
89 | * one must call "kernel.exec".
|
90 | */
|
91 | private execMain;
|
92 | /**
|
93 | * Handles exiting the process
|
94 | */
|
95 | private exitProcess;
|
96 | /**
|
97 | * Register a before hook
|
98 | */
|
99 | before(action: 'run', callback: RunHookCallback): this;
|
100 | before(action: 'find', callback: FindHookCallback): this;
|
101 | /**
|
102 | * Register an after hook
|
103 | */
|
104 | after(action: 'run', callback: RunHookCallback): this;
|
105 | after(action: 'find', callback: FindHookCallback): this;
|
106 | /**
|
107 | * Register an array of command constructors
|
108 | */
|
109 | register(commands: CommandConstructorContract[]): this;
|
110 | /**
|
111 | * Register a global flag. It can be defined in combination with
|
112 | * any command.
|
113 | */
|
114 | flag(name: string, handler: GlobalFlagHandler, options: Partial<Exclude<CommandFlag, 'name' | 'propertyName'>>): this;
|
115 | /**
|
116 | * Use manifest instance to lazy load commands
|
117 | */
|
118 | useManifest(manifestLoader: ManifestLoader): this;
|
119 | /**
|
120 | * Register an exit handler
|
121 | */
|
122 | onExit(callback: (kernel: this) => void | Promise<void>): this;
|
123 | /**
|
124 | * Returns an array of command names suggestions for a given name.
|
125 | */
|
126 | getSuggestions(name: string, distance?: number): string[];
|
127 | /**
|
128 | * Preload the manifest file. Re-running this method twice will
|
129 | * result in a noop
|
130 | */
|
131 | preloadManifest(): Promise<void>;
|
132 | /**
|
133 | * Finds the command from the command line argv array. If command for
|
134 | * the given name doesn't exists, then it will return `null`.
|
135 | *
|
136 | * Does executes the before and after hooks regardless of whether the
|
137 | * command has been found or not
|
138 | */
|
139 | find(argv: string[]): Promise<CommandConstructorContract | null>;
|
140 | /**
|
141 | * Run the default command. The default command doesn't accept
|
142 | * and args or flags.
|
143 | */
|
144 | runDefaultCommand(): Promise<any>;
|
145 | /**
|
146 | * Find if a command is the main command. Main commands are executed
|
147 | * directly from the terminal.
|
148 | */
|
149 | isMain(command: CommandContract): boolean;
|
150 | /**
|
151 | * Enforce mocking the console output. Command logs, tables, prompts
|
152 | * will be mocked
|
153 | */
|
154 | mockConsoleOutput(): this;
|
155 | /**
|
156 | * Toggle interactive state
|
157 | */
|
158 | interactive(state: boolean): this;
|
159 | /**
|
160 | * Execute a command as a sub-command. Do not call "handle" and
|
161 | * always use this method to invoke command programatically
|
162 | */
|
163 | exec(commandName: string, args: string[]): Promise<CommandContract>;
|
164 | /**
|
165 | * Makes instance of a given command by processing command line arguments
|
166 | * and setting them on the command instance
|
167 | */
|
168 | handle(argv: string[]): Promise<void>;
|
169 | /**
|
170 | * Print the help screen for a given command or all commands/flags
|
171 | */
|
172 | printHelp(command?: CommandConstructorContract, commandsToAppend?: ManifestCommand[], aliasesToAppend?: Record<string, string>): void;
|
173 | /**
|
174 | * Trigger kernel to exit the process. The call to this method
|
175 | * is ignored when command is not same the `entryCommand`.
|
176 | *
|
177 | * In other words, subcommands cannot trigger exit
|
178 | */
|
179 | exit(command: CommandContract, error?: any): Promise<void>;
|
180 | }
|