@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.cjs +59 -244
- package/dist/index.d.ts +266 -282
- package/dist/index.mjs +59 -244
- package/package.json +12 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,282 +1,266 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { TCliHelpOptions } from '@prostojs/cli-help';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* @
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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 };
|