@wooksjs/event-cli 0.4.10 → 0.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,282 +1,266 @@
1
- import { CliHelpRenderer } from '@prostojs/cli-help';
2
- import minimist from 'minimist';
3
- import { TCliEntry } from '@prostojs/cli-help';
4
- import { TCliHelpOptions } from '@prostojs/cli-help';
5
- import { TConsoleBase } from '@prostojs/logger';
6
- import { TEmpty } from '@wooksjs/event-core';
7
- import { TEventOptions } from '@wooksjs/event-core';
8
- import { TGenericContextStore } from '@wooksjs/event-core';
9
- import { TProstoRouterPathHandle } from '@prostojs/router';
10
- import { TWooksHandler } from '@wooksjs/wooks';
11
- import { TWooksHandler as TWooksHandler_2 } from 'wooks';
12
- import { TWooksOptions } from 'wooks';
13
- import { Wooks } from 'wooks';
14
- import { WooksAdapterBase } from 'wooks';
15
-
16
- export declare const cliShortcuts: {
17
- cli: string;
18
- };
19
-
20
- /**
21
- * Factory for WooksCli App
22
- * @param opts TWooksCliOptions
23
- * @param wooks Wooks | WooksAdapterBase
24
- * @returns WooksCli
25
- */
26
- export declare function createCliApp(opts?: TWooksCliOptions, wooks?: Wooks | WooksAdapterBase): WooksCli;
27
-
28
- export declare function createCliContext(data: Omit<TCliEventData, 'type'>, options: TEventOptions): {
29
- getCtx: () => TCliContextStore & TGenericContextStore<TCliEventData>;
30
- restoreCtx: () => TGenericContextStore<TEmpty>;
31
- clearCtx: () => null;
32
- store: <K extends "flags" | keyof TGenericContextStore<TCliEventData>>(key: K) => {
33
- value: (TCliContextStore & TGenericContextStore<TCliEventData>)[K];
34
- hook: <K2 extends keyof Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K]>(key2: K2) => {
35
- value: Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K][K2];
36
- isDefined: boolean;
37
- };
38
- init: <K2_1 extends keyof Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K]>[K2_1]) => Required<Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K]>[K2_1];
39
- set: <K2_2 extends keyof Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K]>(key2: K2_2, v: Required<(TCliContextStore & TGenericContextStore<TCliEventData>)[K]>[K2_2]) => Required<(TCliContextStore & TGenericContextStore<TCliEventData>)[K]>[K2_2];
40
- get: <K2_3 extends keyof Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K]>(key2: K2_3) => Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K][K2_3];
41
- has: <K2_4 extends keyof Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K]>(key2: K2_4) => boolean;
42
- del: <K2_5 extends keyof Required<TCliContextStore & TGenericContextStore<TCliEventData>>[K]>(key2: K2_5) => void;
43
- entries: () => [string, unknown][];
44
- clear: () => void;
45
- };
46
- getStore: <K_1 extends "flags" | keyof TGenericContextStore<TCliEventData>>(key: K_1) => (TCliContextStore & TGenericContextStore<TCliEventData>)[K_1];
47
- setStore: <K_2 extends "flags" | keyof TGenericContextStore<TCliEventData>>(key: K_2, v: (TCliContextStore & TGenericContextStore<TCliEventData>)[K_2]) => void;
48
- };
49
-
50
- export declare interface TCliContextStore {
51
- flags?: {
52
- [name: string]: boolean | string;
53
- };
54
- }
55
-
56
- export declare interface TCliEventData {
57
- argv: string[];
58
- pathParams: string[];
59
- command: string;
60
- opts?: minimist.Opts;
61
- type: 'CLI';
62
- cliHelp: TCliHelpRenderer;
63
- }
64
-
65
- export declare type TCliHelpCustom = {
66
- handler: TWooksHandler<any>;
67
- /**
68
- * ### Callback for registered path
69
- *
70
- * @param path registered path
71
- * @param aliasType 0 - direct command, 1 - direct alias, 2 - computed alias
72
- */
73
- cb?: <T>(path: string, aliasType: number, route?: TProstoRouterPathHandle<T>) => void;
74
- };
75
-
76
- export declare type TCliHelpRenderer = CliHelpRenderer<TCliHelpCustom>;
77
-
78
- export declare interface TWooksCliEntry<T> extends Omit<TCliEntry<TWooksHandler_2<T>>, 'custom' | 'command'> {
79
- onRegister?: TCliHelpCustom['cb'];
80
- handler: TWooksHandler_2<T>;
81
- }
82
-
83
- export declare interface TWooksCliOptions {
84
- onError?(e: Error): void;
85
- onNotFound?: TWooksHandler_2<unknown>;
86
- onUnknownCommand?: (params: string[], raiseError: () => void) => unknown;
87
- logger?: TConsoleBase;
88
- eventOptions?: TEventOptions;
89
- cliHelp?: TCliHelpRenderer | TCliHelpOptions;
90
- router?: TWooksOptions['router'];
91
- }
92
-
93
- /**
94
- * ## useAutoHelp
95
- * ### Composable
96
- *
97
- * Prints help if `--help` option provided.
98
- *
99
- * ```js
100
- * // example of use: print help and exit
101
- * app.cli('test', () => {
102
- * useAutoHelp() && process.exit(0)
103
- * return 'hit test command'
104
- * })
105
- *
106
- * // add option -h to print help, no colors
107
- * app.cli('test/nocolors', () => {
108
- * useAutoHelp(['help', 'h'], false) && process.exit(0)
109
- * return 'hit test nocolors command'
110
- * })
111
- * ```
112
- * @param keys default `['help']` - list of options to trigger help render
113
- * @param colors default `true`, prints with colors when true
114
- * @returns true when --help was provided. Otherwise returns false
115
- */
116
- export declare function useAutoHelp(keys?: string[], colors?: boolean): true | undefined;
117
-
118
- /**
119
- * Wrapper on top of useEventContext that provides
120
- * proper context types for CLI event
121
- * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
122
- */
123
- export declare function useCliContext<T extends TEmpty>(): {
124
- getCtx: () => TCliContextStore & T & TGenericContextStore<TCliEventData>;
125
- restoreCtx: () => TGenericContextStore<TEmpty>;
126
- clearCtx: () => null;
127
- store: <K extends "flags" | keyof TGenericContextStore<TCliEventData> | keyof T>(key: K) => {
128
- value: (TCliContextStore & T & TGenericContextStore<TCliEventData>)[K];
129
- hook: <K2 extends keyof Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K]>(key2: K2) => {
130
- value: Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K][K2];
131
- isDefined: boolean;
132
- };
133
- init: <K2_1 extends keyof Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K]>[K2_1]) => Required<Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K]>[K2_1];
134
- set: <K2_2 extends keyof Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K]>(key2: K2_2, v: Required<(TCliContextStore & T & TGenericContextStore<TCliEventData>)[K]>[K2_2]) => Required<(TCliContextStore & T & TGenericContextStore<TCliEventData>)[K]>[K2_2];
135
- get: <K2_3 extends keyof Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K]>(key2: K2_3) => Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K][K2_3];
136
- has: <K2_4 extends keyof Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K]>(key2: K2_4) => boolean;
137
- del: <K2_5 extends keyof Required<TCliContextStore & T & TGenericContextStore<TCliEventData>>[K]>(key2: K2_5) => void;
138
- entries: () => [string, unknown][];
139
- clear: () => void;
140
- };
141
- getStore: <K_1 extends "flags" | keyof TGenericContextStore<TCliEventData> | keyof T>(key: K_1) => (TCliContextStore & T & TGenericContextStore<TCliEventData>)[K_1];
142
- setStore: <K_2 extends "flags" | keyof TGenericContextStore<TCliEventData> | keyof T>(key: K_2, v: (TCliContextStore & T & TGenericContextStore<TCliEventData>)[K_2]) => void;
143
- };
144
-
145
- /**
146
- * ## useCliHelp
147
- * ### Composable
148
- * ```js
149
- * // example of printing cli instructions
150
- * const { print } = useCliHelp()
151
- * // print with colors
152
- * print(true)
153
- * // print with no colors
154
- * // print(false)
155
- * ```
156
- * @returns
157
- */
158
- export declare function useCliHelp(): {
159
- getCliHelp: () => TCliHelpRenderer;
160
- getEntry: () => TCliEntry<TCliHelpCustom>;
161
- render: (width?: number, withColors?: boolean) => string[];
162
- print: (withColors?: boolean) => void;
163
- };
164
-
165
- /**
166
- * Getter for Cli Option value
167
- *
168
- * @param name name of the option
169
- * @returns value of a CLI option
170
- */
171
- export declare function useCliOption(name: string): string | boolean;
172
-
173
- /**
174
- * Get CLI Options
175
- *
176
- * @returns an object with CLI options
177
- */
178
- export declare function useCliOptions(): {
179
- [name: string]: string | boolean;
180
- };
181
-
182
- /**
183
- * ##useCommandLookupHelp
184
- * ### Composable
185
- *
186
- * Tries to find valid command based on provided command.
187
- *
188
- * If manages to find a valid command, throws an error
189
- * suggesting a list of valid commands
190
- *
191
- * Best to use in `onUnknownCommand` callback:
192
- *
193
- * ```js
194
- * const app = createCliApp({
195
- * onUnknownCommand: (path, raiseError) => {
196
- * // will throw an error suggesting a list
197
- * // of valid commands if could find some
198
- * useCommandLookupHelp()
199
- * // fallback to a regular error handler
200
- * raiseError()
201
- * },
202
- * })
203
- * ```
204
- *
205
- * @param lookupDepth depth of search in backwards
206
- * @example
207
- *
208
- * For provided command `run test:drive dir`
209
- * - lookup1: `run test:drive dir` (deep = 0)
210
- * - lookup2: `run test:drive` (deep = 1)
211
- * - lookup3: `run test` (deep = 2)
212
- * - lookup4: `run` (deep = 3)
213
- * ...
214
- */
215
- export declare function useCommandLookupHelp(lookupDepth?: number): void;
216
-
217
- export declare class WooksCli extends WooksAdapterBase {
218
- protected opts?: TWooksCliOptions | undefined;
219
- protected logger: TConsoleBase;
220
- protected cliHelp: TCliHelpRenderer;
221
- constructor(opts?: TWooksCliOptions | undefined, wooks?: Wooks | WooksAdapterBase);
222
- /**
223
- * ### Register CLI Command
224
- * Command path segments may be separated by / or space.
225
- *
226
- * For example the folowing path are interpreted the same:
227
- * - "command test use:dev :name"
228
- * - "command/test/use:dev/:name"
229
- *
230
- * Where name will become an argument
231
- *
232
- * ```js
233
- * // example without options
234
- * app.cli('command/:arg', () => 'arg = ' + useRouteParams().params.arg )
235
- *
236
- * // example with options
237
- * app.cli('command/:arg', {
238
- * description: 'Description of the command',
239
- * options: [{ keys: ['project', 'p'], description: 'Description of the option', value: 'myProject' }],
240
- * args: { arg: 'Description of the arg' },
241
- * aliases: ['cmd'], // alias "cmd/:arg" will be registered
242
- * examples: [{
243
- * description: 'Example of usage with someProject',
244
- * cmd: 'argValue -p=someProject',
245
- * // will result in help display:
246
- * // "# Example of usage with someProject\n" +
247
- * // "$ myCli command argValue -p=someProject\n"
248
- * }],
249
- * handler: () => 'arg = ' + useRouteParams().params.arg
250
- * })
251
- * ```
252
- *
253
- * @param path command path
254
- * @param _options handler or options
255
- *
256
- * @returns
257
- */
258
- cli<ResType = unknown, ParamsType = Record<string, string | string[]>>(path: string, _options: TWooksCliEntry<ResType> | TWooksHandler_2<ResType>): TProstoRouterPathHandle<ParamsType>;
259
- protected alreadyComputedAliases: boolean;
260
- protected computeAliases(): void;
261
- /**
262
- * ## run
263
- * ### Start command processing
264
- * Triggers command processing
265
- *
266
- * By default takes `process.argv.slice(2)` as a command
267
- *
268
- * It's possible to replace the command by passing an argument
269
- *
270
- * @param _argv optionally overwrite `process.argv.slice(2)` with your `argv` array
271
- */
272
- run(_argv?: string[], _opts?: minimist.Opts): Promise<void>;
273
- protected onError(e: Error): void;
274
- /**
275
- * Triggers `unknown command` processing and callbacks
276
- * @param pathParams `string[]` containing command
277
- */
278
- onUnknownCommand(pathParams: string[]): void;
279
- protected error(e: string | Error): void;
280
- }
281
-
282
- export { }
1
+ import * as _wooksjs_event_core from '@wooksjs/event-core';
2
+ import { TEventOptions, TEmpty } from '@wooksjs/event-core';
3
+ import * as _prostojs_cli_help from '@prostojs/cli-help';
4
+ import { CliHelpRenderer, TCliHelpOptions, TCliEntry } from '@prostojs/cli-help';
5
+ import * as _prostojs_router from '@prostojs/router';
6
+ import { TProstoRouterPathHandle } from '@prostojs/router';
7
+ import { TWooksHandler, TWooksOptions, WooksAdapterBase, Wooks } from 'wooks';
8
+ import minimist from 'minimist';
9
+ import { TConsoleBase } from '@prostojs/logger';
10
+
11
+ interface TCliEventData {
12
+ argv: string[];
13
+ pathParams: string[];
14
+ command: string;
15
+ opts?: minimist.Opts;
16
+ type: 'CLI';
17
+ cliHelp: TCliHelpRenderer;
18
+ }
19
+ interface TCliContextStore {
20
+ flags?: {
21
+ [name: string]: boolean | string;
22
+ };
23
+ }
24
+ type TCliHelpCustom = {
25
+ handler: TWooksHandler<any>;
26
+ /**
27
+ * ### Callback for registered path
28
+ *
29
+ * @param path registered path
30
+ * @param aliasType 0 - direct command, 1 - direct alias, 2 - computed alias
31
+ */
32
+ cb?: <T>(path: string, aliasType: number, route?: TProstoRouterPathHandle<T>) => void;
33
+ };
34
+ type TCliHelpRenderer = CliHelpRenderer<TCliHelpCustom>;
35
+
36
+ declare function createCliContext(data: Omit<TCliEventData, 'type'>, options: TEventOptions): {
37
+ getCtx: () => TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>;
38
+ restoreCtx: () => _wooksjs_event_core.TGenericContextStore<TEmpty>;
39
+ clearCtx: () => null;
40
+ store: <K extends "flags" | keyof _wooksjs_event_core.TGenericContextStore<TCliEventData>>(key: K) => {
41
+ value: (TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K];
42
+ hook: <K2 extends keyof Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2) => {
43
+ value: Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K][K2];
44
+ isDefined: boolean;
45
+ };
46
+ init: <K2_1 extends keyof Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>[K2_1]) => Required<Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>[K2_1];
47
+ set: <K2_2 extends keyof Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_2, v: Required<(TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K]>[K2_2]) => Required<(TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K]>[K2_2];
48
+ get: <K2_3 extends keyof Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_3) => Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K][K2_3];
49
+ has: <K2_4 extends keyof Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_4) => boolean;
50
+ del: <K2_5 extends keyof Required<TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_5) => void;
51
+ entries: () => [string, unknown][];
52
+ clear: () => void;
53
+ };
54
+ getStore: <K_1 extends "flags" | keyof _wooksjs_event_core.TGenericContextStore<TCliEventData>>(key: K_1) => (TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K_1];
55
+ setStore: <K_2 extends "flags" | keyof _wooksjs_event_core.TGenericContextStore<TCliEventData>>(key: K_2, v: (TCliContextStore & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K_2]) => void;
56
+ };
57
+ /**
58
+ * Wrapper on top of useEventContext that provides
59
+ * proper context types for CLI event
60
+ * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
61
+ */
62
+ declare function useCliContext<T extends TEmpty>(): {
63
+ getCtx: () => TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>;
64
+ restoreCtx: () => _wooksjs_event_core.TGenericContextStore<TEmpty>;
65
+ clearCtx: () => null;
66
+ store: <K extends "flags" | keyof _wooksjs_event_core.TGenericContextStore<TCliEventData> | keyof T>(key: K) => {
67
+ value: (TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K];
68
+ hook: <K2 extends keyof Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2) => {
69
+ value: Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K][K2];
70
+ isDefined: boolean;
71
+ };
72
+ init: <K2_1 extends keyof Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_1, getter: () => Required<Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>[K2_1]) => Required<Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>[K2_1];
73
+ set: <K2_2 extends keyof Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_2, v: Required<(TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K]>[K2_2]) => Required<(TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K]>[K2_2];
74
+ get: <K2_3 extends keyof Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_3) => Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K][K2_3];
75
+ has: <K2_4 extends keyof Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_4) => boolean;
76
+ del: <K2_5 extends keyof Required<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>[K]>(key2: K2_5) => void;
77
+ entries: () => [string, unknown][];
78
+ clear: () => void;
79
+ };
80
+ getStore: <K_1 extends "flags" | keyof _wooksjs_event_core.TGenericContextStore<TCliEventData> | keyof T>(key: K_1) => (TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K_1];
81
+ setStore: <K_2 extends "flags" | keyof _wooksjs_event_core.TGenericContextStore<TCliEventData> | keyof T>(key: K_2, v: (TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>)[K_2]) => void;
82
+ };
83
+
84
+ declare const cliShortcuts: {
85
+ cli: string;
86
+ };
87
+ interface TWooksCliOptions {
88
+ onError?(e: Error): void;
89
+ onNotFound?: TWooksHandler<unknown>;
90
+ onUnknownCommand?: (params: string[], raiseError: () => void) => unknown;
91
+ logger?: TConsoleBase;
92
+ eventOptions?: TEventOptions;
93
+ cliHelp?: TCliHelpRenderer | TCliHelpOptions;
94
+ router?: TWooksOptions['router'];
95
+ }
96
+ interface TWooksCliEntry<T> extends Omit<TCliEntry<TWooksHandler<T>>, 'custom' | 'command'> {
97
+ onRegister?: TCliHelpCustom['cb'];
98
+ handler: TWooksHandler<T>;
99
+ }
100
+ declare class WooksCli extends WooksAdapterBase {
101
+ protected opts?: TWooksCliOptions | undefined;
102
+ protected logger: TConsoleBase;
103
+ protected cliHelp: TCliHelpRenderer;
104
+ constructor(opts?: TWooksCliOptions | undefined, wooks?: Wooks | WooksAdapterBase);
105
+ /**
106
+ * ### Register CLI Command
107
+ * Command path segments may be separated by / or space.
108
+ *
109
+ * For example the folowing path are interpreted the same:
110
+ * - "command test use:dev :name"
111
+ * - "command/test/use:dev/:name"
112
+ *
113
+ * Where name will become an argument
114
+ *
115
+ * ```js
116
+ * // example without options
117
+ * app.cli('command/:arg', () => 'arg = ' + useRouteParams().params.arg )
118
+ *
119
+ * // example with options
120
+ * app.cli('command/:arg', {
121
+ * description: 'Description of the command',
122
+ * options: [{ keys: ['project', 'p'], description: 'Description of the option', value: 'myProject' }],
123
+ * args: { arg: 'Description of the arg' },
124
+ * aliases: ['cmd'], // alias "cmd/:arg" will be registered
125
+ * examples: [{
126
+ * description: 'Example of usage with someProject',
127
+ * cmd: 'argValue -p=someProject',
128
+ * // will result in help display:
129
+ * // "# Example of usage with someProject\n" +
130
+ * // "$ myCli command argValue -p=someProject\n"
131
+ * }],
132
+ * handler: () => 'arg = ' + useRouteParams().params.arg
133
+ * })
134
+ * ```
135
+ *
136
+ * @param path command path
137
+ * @param _options handler or options
138
+ *
139
+ * @returns
140
+ */
141
+ cli<ResType = unknown, ParamsType = Record<string, string | string[]>>(path: string, _options: TWooksCliEntry<ResType> | TWooksHandler<ResType>): _prostojs_router.TProstoRouterPathHandle<ParamsType>;
142
+ protected alreadyComputedAliases: boolean;
143
+ protected computeAliases(): void;
144
+ /**
145
+ * ## run
146
+ * ### Start command processing
147
+ * Triggers command processing
148
+ *
149
+ * By default takes `process.argv.slice(2)` as a command
150
+ *
151
+ * It's possible to replace the command by passing an argument
152
+ *
153
+ * @param _argv optionally overwrite `process.argv.slice(2)` with your `argv` array
154
+ */
155
+ run(_argv?: string[], _opts?: minimist.Opts): Promise<void>;
156
+ protected onError(e: Error): void;
157
+ /**
158
+ * Triggers `unknown command` processing and callbacks
159
+ * @param pathParams `string[]` containing command
160
+ */
161
+ onUnknownCommand(pathParams: string[]): void;
162
+ protected error(e: string | Error): void;
163
+ }
164
+ /**
165
+ * Factory for WooksCli App
166
+ * @param opts TWooksCliOptions
167
+ * @param wooks Wooks | WooksAdapterBase
168
+ * @returns WooksCli
169
+ */
170
+ declare function createCliApp(opts?: TWooksCliOptions, wooks?: Wooks | WooksAdapterBase): WooksCli;
171
+
172
+ /**
173
+ * Get CLI Options
174
+ *
175
+ * @returns an object with CLI options
176
+ */
177
+ declare function useCliOptions(): {
178
+ [name: string]: string | boolean;
179
+ };
180
+ /**
181
+ * Getter for Cli Option value
182
+ *
183
+ * @param name name of the option
184
+ * @returns value of a CLI option
185
+ */
186
+ declare function useCliOption(name: string): string | boolean;
187
+
188
+ /**
189
+ * ## useCliHelp
190
+ * ### Composable
191
+ * ```js
192
+ * // example of printing cli instructions
193
+ * const { print } = useCliHelp()
194
+ * // print with colors
195
+ * print(true)
196
+ * // print with no colors
197
+ * // print(false)
198
+ * ```
199
+ * @returns
200
+ */
201
+ declare function useCliHelp(): {
202
+ getCliHelp: () => TCliHelpRenderer;
203
+ getEntry: () => _prostojs_cli_help.TCliEntry<TCliHelpCustom>;
204
+ render: (width?: number, withColors?: boolean) => string[];
205
+ print: (withColors?: boolean) => void;
206
+ };
207
+ /**
208
+ * ## useAutoHelp
209
+ * ### Composable
210
+ *
211
+ * Prints help if `--help` option provided.
212
+ *
213
+ * ```js
214
+ * // example of use: print help and exit
215
+ * app.cli('test', () => {
216
+ * useAutoHelp() && process.exit(0)
217
+ * return 'hit test command'
218
+ * })
219
+ *
220
+ * // add option -h to print help, no colors
221
+ * app.cli('test/nocolors', () => {
222
+ * useAutoHelp(['help', 'h'], false) && process.exit(0)
223
+ * return 'hit test nocolors command'
224
+ * })
225
+ * ```
226
+ * @param keys default `['help']` - list of options to trigger help render
227
+ * @param colors default `true`, prints with colors when true
228
+ * @returns true when --help was provided. Otherwise returns false
229
+ */
230
+ declare function useAutoHelp(keys?: string[], colors?: boolean): true | undefined;
231
+ /**
232
+ * ##useCommandLookupHelp
233
+ * ### Composable
234
+ *
235
+ * Tries to find valid command based on provided command.
236
+ *
237
+ * If manages to find a valid command, throws an error
238
+ * suggesting a list of valid commands
239
+ *
240
+ * Best to use in `onUnknownCommand` callback:
241
+ *
242
+ * ```js
243
+ * const app = createCliApp({
244
+ * onUnknownCommand: (path, raiseError) => {
245
+ * // will throw an error suggesting a list
246
+ * // of valid commands if could find some
247
+ * useCommandLookupHelp()
248
+ * // fallback to a regular error handler
249
+ * raiseError()
250
+ * },
251
+ * })
252
+ * ```
253
+ *
254
+ * @param lookupDepth depth of search in backwards
255
+ * @example
256
+ *
257
+ * For provided command `run test:drive dir`
258
+ * - lookup1: `run test:drive dir` (deep = 0)
259
+ * - lookup2: `run test:drive` (deep = 1)
260
+ * - lookup3: `run test` (deep = 2)
261
+ * - lookup4: `run` (deep = 3)
262
+ * ...
263
+ */
264
+ declare function useCommandLookupHelp(lookupDepth?: number): void;
265
+
266
+ export { type TCliContextStore, type TCliEventData, type TCliHelpCustom, type TCliHelpRenderer, type TWooksCliEntry, type TWooksCliOptions, WooksCli, cliShortcuts, createCliApp, createCliContext, useAutoHelp, useCliContext, useCliHelp, useCliOption, useCliOptions, useCommandLookupHelp };