@flowscripter/dynamic-cli-framework 1.1.5 → 1.2.0
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/.github/workflows/release-bun-library.yml +1 -0
- package/README/core-commands.md +40 -0
- package/README/core-service-providers.md +198 -0
- package/README/development.md +60 -0
- package/README/implementation-details.md +474 -0
- package/README/key-concepts.md +751 -0
- package/README.md +12 -1413
- package/bun.lock +20 -18
- package/index.ts +98 -1
- package/package.json +8 -7
- package/src/api/BaseCLIFeatureOptions.ts +10 -0
- package/src/api/CLIConfig.ts +5 -0
- package/src/api/RunResult.ts +16 -0
- package/src/api/argument/Argument.ts +40 -1
- package/src/api/argument/ArgumentValueTypes.ts +1 -1
- package/src/api/command/SubCommand.ts +1 -1
- package/src/api/service/ServiceProvider.ts +3 -3
- package/src/api/service/core/ArgumentPrompterService.ts +10 -0
- package/src/api/service/core/AsciiBannerGeneratorService.ts +44 -7
- package/src/api/service/core/CompletionService.ts +36 -0
- package/src/api/service/core/DataDumpGeneratorService.ts +27 -0
- package/src/api/service/core/ImagePrinterService.ts +26 -0
- package/src/api/service/core/KeyValueService.ts +22 -5
- package/src/api/service/core/PrinterService.ts +127 -1
- package/src/api/service/core/PrompterService.ts +49 -0
- package/src/api/service/core/SecretService.ts +27 -0
- package/src/api/service/core/ShutdownService.ts +17 -1
- package/src/api/service/core/Table.ts +85 -0
- package/src/api/service/core/TableGeneratorService.ts +38 -0
- package/src/api/service/core/TreePrinterService.ts +11 -0
- package/src/cli/BaseCLI.ts +116 -44
- package/src/cli/DefaultRuntimeCLI.ts +10 -18
- package/src/command/CompletionCommand.ts +179 -0
- package/src/command/MultiCommandCliHelpCommand.ts +20 -32
- package/src/command/SingleCommandCliHelpCommand.ts +10 -1
- package/src/launcher.ts +16 -58
- package/src/runtime/command/CommandValidator.ts +70 -6
- package/src/runtime/runner.ts +112 -31
- package/src/runtime/scanner.ts +18 -15
- package/src/runtime/values/argumentValueValidation.ts +93 -10
- package/src/runtime/values/globalCommandValuePopulation.ts +1 -1
- package/src/runtime/values/subCommandValuePopulation.ts +9 -8
- package/src/service/argumentPrompter/ArgumentPrompterServiceProvider.ts +34 -0
- package/src/service/argumentPrompter/DefaultArgumentPrompterService.ts +330 -0
- package/src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.ts +1 -1
- package/src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.ts +254 -17
- package/src/service/banner/BannerServiceProvider.ts +2 -2
- package/src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.ts +85 -0
- package/src/service/chiselAsciiBannerGenerator/chisel.flf.json +3 -0
- package/src/service/completion/CompletionServiceProvider.ts +212 -0
- package/src/service/completion/DefaultCompletionService.ts +364 -0
- package/src/service/completion/shell/ShellHandler.ts +16 -0
- package/src/service/completion/shell/bash.ts +47 -0
- package/src/service/completion/shell/fish.ts +43 -0
- package/src/service/completion/shell/powershell.ts +66 -0
- package/src/service/completion/shell/zsh.ts +50 -0
- package/src/service/configuration/ConfigurationServiceProvider.ts +138 -42
- package/src/service/configuration/DefaultKeyValueService.ts +53 -7
- package/src/service/configuration/DefaultSecretService.ts +85 -0
- package/src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.ts +41 -0
- package/src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.ts +80 -0
- package/src/service/imagePrinter/DefaultImagePrinterService.ts +23 -0
- package/src/service/imagePrinter/ImagePrinterServiceProvider.ts +32 -0
- package/src/service/prettyPrinter/PrettyPrinterServiceProvider.ts +1 -1
- package/src/service/printer/DefaultPrinterService.ts +147 -27
- package/src/service/printer/PrinterServiceProvider.ts +7 -7
- package/src/service/printer/command/LogLevelCommand.ts +2 -1
- package/src/service/printer/command/NoHyperlinksCommand.ts +40 -0
- package/src/service/printer/terminal/Progress.ts +21 -4
- package/src/service/printer/terminal/Spinner.ts +32 -8
- package/src/service/printer/terminal/Theme.ts +1 -1
- package/src/service/prompter/DefaultPrompterService.ts +87 -0
- package/src/service/prompter/PrompterServiceProvider.ts +36 -0
- package/src/service/prompter/command/NoPromptCommand.ts +40 -0
- package/src/service/prompter/prompt/PromptContext.ts +47 -0
- package/src/service/prompter/prompt/promptAcknowledge.ts +28 -0
- package/src/service/prompter/prompt/promptMultiSelect.ts +99 -0
- package/src/service/prompter/prompt/promptOpenUrl.ts +97 -0
- package/src/service/prompter/prompt/promptSingleSelect.ts +102 -0
- package/src/service/prompter/prompt/promptText.ts +107 -0
- package/src/service/prompter/prompt/promptToggle.ts +28 -0
- package/src/service/shutdown/DefaultShutdownService.ts +13 -0
- package/src/service/shutdown/ShutdownServiceProvider.ts +28 -9
- package/src/service/shutdown/ShutdownState.ts +5 -0
- package/src/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.ts +1 -1
- package/src/service/tableGenerator/DefaultTableGeneratorService.ts +415 -0
- package/src/service/tableGenerator/TableGeneratorServiceProvider.ts +43 -0
- package/src/service/treePrinter/DefaultTreePrinterService.ts +49 -0
- package/src/service/treePrinter/TreePrinterServiceProvider.ts +40 -0
- package/src/terminal/Ansi.ts +27 -0
- package/src/terminal/ImageRenderer.ts +199 -0
- package/src/terminal/KeyReader.ts +23 -0
- package/src/terminal/PngDecoder.ts +143 -0
- package/src/{service/printer/terminal → terminal}/Styler.ts +3 -0
- package/src/{service/printer/terminal → terminal}/Terminal.ts +1 -0
- package/src/terminal/TtyKeyReader.ts +83 -0
- package/src/terminal/TtyStyler.ts +78 -0
- package/src/{service/printer/terminal → terminal}/TtyTerminal.ts +9 -1
- package/src/terminal/supportsHyperlinks.ts +110 -0
- package/src/util/configHelper.ts +2 -2
- package/src/util/envVarHelper.ts +2 -2
- package/src/util/helpHelper.ts +139 -123
- package/src/util/logger.ts +16 -14
- package/src/util/runnerHelper.ts +41 -0
- package/tests/cli/BaseCLI.test.ts +50 -54
- package/tests/command/CompletionCommand.test.ts +68 -0
- package/tests/command/UsageCommand.test.ts +3 -2
- package/tests/command/VersionCommand.test.ts +3 -2
- package/tests/fixtures/Context.ts +9 -2
- package/tests/fixtures/util.ts +1 -1
- package/tests/runtime/command/CommandValidator.test.ts +103 -0
- package/tests/runtime/parser.test.ts +9 -7
- package/tests/runtime/registry/DefaultServiceProviderRegistry.test.ts +3 -3
- package/tests/runtime/runner.test.ts +36 -0
- package/tests/runtime/values/argumentValueValidation.test.ts +215 -1
- package/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.ts +47 -0
- package/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.ts +754 -0
- package/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.ts +5 -4
- package/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.ts +163 -3
- package/tests/service/asciiBannerGenerator/__snapshots__/DefaultAsciiBannerGeneratorService.test.ts.snap +1 -1
- package/tests/service/banner/BannerServiceProvider.test.ts +8 -4
- package/tests/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.test.ts +52 -0
- package/tests/service/completion/CompletionServiceProvider.test.ts +404 -0
- package/tests/service/completion/DefaultCompletionService.test.ts +278 -0
- package/tests/service/completion/shell/bash.test.ts +73 -0
- package/tests/service/completion/shell/fish.test.ts +62 -0
- package/tests/service/completion/shell/powershell.test.ts +59 -0
- package/tests/service/completion/shell/zsh.test.ts +60 -0
- package/tests/service/configuration/ConfigurationServiceProvider.test.ts +24 -12
- package/tests/service/configuration/DefaultKeyValueService.test.ts +118 -16
- package/tests/service/configuration/DefaultSecretService.test.ts +148 -0
- package/tests/service/configuration/command/ConfigCommand.test.ts +29 -0
- package/tests/service/configuration/command/DumpConfigCommand.test.ts +60 -0
- package/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.ts +57 -0
- package/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.ts +217 -0
- package/tests/service/imagePrinter/DefaultImagePrinterService.test.ts +96 -0
- package/tests/service/imagePrinter/ImagePrinterServiceProvider.test.ts +17 -0
- package/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.ts +2 -2
- package/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.ts +5 -4
- package/tests/service/printer/DefaultPrinterService.test.ts +233 -2
- package/tests/service/printer/PrinterServiceProvider.test.ts +6 -5
- package/tests/service/printer/command/DarkModeCommand.test.ts +83 -0
- package/tests/service/printer/command/LogLevelCommand.test.ts +8 -6
- package/tests/service/printer/command/NoColorCommand.test.ts +83 -0
- package/tests/service/printer/command/NoHyperlinksCommand.test.ts +89 -0
- package/tests/service/printer/terminal/Progress.test.ts +64 -4
- package/tests/service/printer/terminal/Spinner.test.ts +44 -3
- package/tests/service/prompter/DefaultPrompterService.test.ts +615 -0
- package/tests/service/prompter/PrompterServiceProvider.test.ts +47 -0
- package/tests/service/prompter/command/NoPromptCommand.test.ts +58 -0
- package/tests/service/shutdown/ShutdownServiceProvider.test.ts +4 -2
- package/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.ts +3 -2
- package/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.ts +5 -4
- package/tests/service/tableGenerator/DefaultTableGeneratorService.test.ts +363 -0
- package/tests/service/tableGenerator/TableGeneratorServiceProvider.test.ts +47 -0
- package/tests/service/treePrinter/DefaultTreePrinterService.test.ts +144 -0
- package/tests/service/treePrinter/TreePrinterServiceProvider.test.ts +55 -0
- package/tests/terminal/ImageRenderer.test.ts +161 -0
- package/tests/terminal/PngDecoder.test.ts +223 -0
- package/tests/terminal/supportsHyperlinks.test.ts +149 -0
- package/tests/util/configHelper.test.ts +4 -4
- package/tests/util/logger.test.ts +23 -1
- package/tsconfig.json +31 -0
- package/src/service/printer/terminal/Ansi.ts +0 -10
- package/src/service/printer/terminal/TtyStyler.ts +0 -39
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
export const KEY_VALUE_SERVICE_ID =
|
|
2
2
|
"@flowscripter/dynamic-cli-framework/key-value-service";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The sentinel prefix used to indicate a value is stored as an OS-native secret.
|
|
6
|
+
* Values starting with this prefix are resolved via the {@link SecretService}.
|
|
7
|
+
* This prefix is reserved and must not be used for regular key-value data.
|
|
8
|
+
*/
|
|
9
|
+
export const SECRET_SENTINEL_PREFIX = "__SECRET__:";
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Service providing keystore functionality for the CLI. The keystore data is scoped to the
|
|
6
|
-
* service or {@link Command} instances accessing this service via {@link Context.getServiceById}
|
|
13
|
+
* service or {@link Command} instances accessing this service via {@link Context.getServiceById}.
|
|
14
|
+
*
|
|
15
|
+
* Values can optionally be stored as OS-native secrets using the `isSecret` parameter on
|
|
16
|
+
* {@link setKey}. Secret values are stored via {@link SecretService} and only a sentinel
|
|
17
|
+
* reference is kept in the key-value Map. The sentinel prefix `__SECRET__:` is reserved.
|
|
7
18
|
*/
|
|
8
19
|
export default interface KeyValueService {
|
|
9
20
|
/**
|
|
10
21
|
* Get a value for a specified key in the keystore.
|
|
22
|
+
* If the stored value is a secret sentinel, the actual value is retrieved from the OS secret store.
|
|
11
23
|
*/
|
|
12
|
-
getKey(key: string): string
|
|
24
|
+
getKey(key: string): Promise<string>;
|
|
13
25
|
|
|
14
26
|
/**
|
|
15
27
|
* Set a value for a specified key in the keystore.
|
|
28
|
+
*
|
|
29
|
+
* @param isSecret if true, the value is stored in the OS-native secret store and a sentinel
|
|
30
|
+
* reference is kept in the key-value Map. Requires that the service was constructed with
|
|
31
|
+
* secret support enabled.
|
|
16
32
|
*/
|
|
17
|
-
setKey(key: string, value: string): void
|
|
33
|
+
setKey(key: string, value: string, isSecret?: boolean): Promise<void>;
|
|
18
34
|
|
|
19
35
|
/**
|
|
20
36
|
* Check if a value for a specified key exists in the keystore.
|
|
21
37
|
*/
|
|
22
|
-
hasKey(key: string): boolean
|
|
38
|
+
hasKey(key: string): Promise<boolean>;
|
|
23
39
|
|
|
24
40
|
/**
|
|
25
41
|
* Delete the value for a specified key in the keystore.
|
|
42
|
+
* If the stored value is a secret sentinel, the secret is also deleted from the OS secret store.
|
|
26
43
|
*/
|
|
27
|
-
deleteKey(key: string): void
|
|
44
|
+
deleteKey(key: string): Promise<void>;
|
|
28
45
|
}
|
|
@@ -12,6 +12,22 @@ export enum Level {
|
|
|
12
12
|
ERROR = 3,
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Enum of spinner animation styles.
|
|
17
|
+
*/
|
|
18
|
+
export enum SpinnerStyle {
|
|
19
|
+
BOX = "BOX",
|
|
20
|
+
STAR = "STAR",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Enum of progress bar rendering styles.
|
|
25
|
+
*/
|
|
26
|
+
export enum ProgressStyle {
|
|
27
|
+
STROKE = "STROKE",
|
|
28
|
+
FILL = "FILL",
|
|
29
|
+
}
|
|
30
|
+
|
|
15
31
|
/**
|
|
16
32
|
* Enum of message icons.
|
|
17
33
|
*/
|
|
@@ -38,6 +54,11 @@ export default interface PrinterService {
|
|
|
38
54
|
*/
|
|
39
55
|
colorEnabled: boolean;
|
|
40
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Disable or enable hyperlink output for messages.
|
|
59
|
+
*/
|
|
60
|
+
hyperlinksEnabled: boolean;
|
|
61
|
+
|
|
41
62
|
/**
|
|
42
63
|
* Enable or disable dark mode. Default is disabled i.e. `false`.
|
|
43
64
|
*/
|
|
@@ -143,6 +164,108 @@ export default interface PrinterService {
|
|
|
143
164
|
*/
|
|
144
165
|
color(message: string, hexFormattedColor: string): string;
|
|
145
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Return the provided message so that the background is colored as primary content.
|
|
169
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
170
|
+
*/
|
|
171
|
+
backgroundPrimary(message: string): string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Return the provided message so that the background is colored as secondary content.
|
|
175
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
176
|
+
*/
|
|
177
|
+
backgroundSecondary(message: string): string;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Return the provided message so that the background is colored as emphasised content.
|
|
181
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
182
|
+
*/
|
|
183
|
+
backgroundEmphasised(message: string): string;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Return the provided message so that the background is colored as selected content.
|
|
187
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
188
|
+
*/
|
|
189
|
+
backgroundSelected(message: string): string;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Return the provided message so that the background is yellow.
|
|
193
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
194
|
+
*/
|
|
195
|
+
backgroundYellow(message: string): string;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Return the provided message so that the background is orange.
|
|
199
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
200
|
+
*/
|
|
201
|
+
backgroundOrange(message: string): string;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Return the provided message so that the background is red.
|
|
205
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
206
|
+
*/
|
|
207
|
+
backgroundRed(message: string): string;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Return the provided message so that the background is magenta.
|
|
211
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
212
|
+
*/
|
|
213
|
+
backgroundMagenta(message: string): string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Return the provided message so that the background is violet.
|
|
217
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
218
|
+
*/
|
|
219
|
+
backgroundViolet(message: string): string;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Return the provided message so that the background is blue.
|
|
223
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
224
|
+
*/
|
|
225
|
+
backgroundBlue(message: string): string;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Return the provided message so that the background is cyan.
|
|
229
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
230
|
+
*/
|
|
231
|
+
backgroundCyan(message: string): string;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Return the provided message so that the background is green.
|
|
235
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
236
|
+
*/
|
|
237
|
+
backgroundGreen(message: string): string;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Return the provided message so that the background is the specified color.
|
|
241
|
+
* Has no effect if {@link colorEnabled} is `false`.
|
|
242
|
+
*
|
|
243
|
+
* @param message the message to color.
|
|
244
|
+
* @param hexFormattedColor the color to use. This should be a valid hex formatted string e.g. "#rrggbb".
|
|
245
|
+
*/
|
|
246
|
+
backgroundColor(message: string, hexFormattedColor: string): string;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Return the provided text wrapped in an OSC 8 hyperlink to the specified URL.
|
|
250
|
+
* Has no effect if {@link hyperlinksEnabled} is `false`, in which case the text is returned unchanged.
|
|
251
|
+
*
|
|
252
|
+
* @param text the text to display as the hyperlink.
|
|
253
|
+
* @param url the URL target of the hyperlink.
|
|
254
|
+
*/
|
|
255
|
+
hyperlink(text: string, url: string): string;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* The number of columns available on the stdout terminal.
|
|
259
|
+
* Defaults to 80 if the terminal width cannot be determined.
|
|
260
|
+
*/
|
|
261
|
+
stdoutColumns(): number;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The number of columns available on the stderr terminal.
|
|
265
|
+
* Defaults to 80 if the terminal width cannot be determined.
|
|
266
|
+
*/
|
|
267
|
+
stderrColumns(): number;
|
|
268
|
+
|
|
146
269
|
/**
|
|
147
270
|
* Print a message on `stdout`.
|
|
148
271
|
* Will be displayed as primary content if {@link colorEnabled} is `true`.
|
|
@@ -215,8 +338,9 @@ export default interface PrinterService {
|
|
|
215
338
|
* NOTE: If any progress bars are currently displayed they will be hidden.
|
|
216
339
|
*
|
|
217
340
|
* @param message the message to output after the spinner.
|
|
341
|
+
* @param style optional spinner animation style, defaults to {@link SpinnerStyle.BOX}.
|
|
218
342
|
*/
|
|
219
|
-
showSpinner(message: string): Promise<void>;
|
|
343
|
+
showSpinner(message: string, style?: SpinnerStyle): Promise<void>;
|
|
220
344
|
|
|
221
345
|
/**
|
|
222
346
|
* Hide the spinner.
|
|
@@ -238,6 +362,7 @@ export default interface PrinterService {
|
|
|
238
362
|
* @param message an optional message for the progress bar.
|
|
239
363
|
* @param total the total value which equates to 100% complete, defaults to `100`.
|
|
240
364
|
* @param current the current value which is a portion of the total value, defaults to `0`.
|
|
365
|
+
* @param style optional progress bar rendering style, defaults to {@link ProgressStyle.STROKE}.
|
|
241
366
|
*
|
|
242
367
|
* @return a handle to use when invoking {@link updateProgressBar}.
|
|
243
368
|
*/
|
|
@@ -246,6 +371,7 @@ export default interface PrinterService {
|
|
|
246
371
|
message?: string,
|
|
247
372
|
total?: number,
|
|
248
373
|
current?: number,
|
|
374
|
+
style?: ProgressStyle,
|
|
249
375
|
): Promise<number>;
|
|
250
376
|
|
|
251
377
|
/**
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ArgumentSingleValueType } from "../../argument/ArgumentValueTypes.ts";
|
|
2
|
+
|
|
3
|
+
export const PROMPTER_SERVICE_ID =
|
|
4
|
+
"@flowscripter/dynamic-cli-framework/prompter-service";
|
|
5
|
+
|
|
6
|
+
export enum PromptType {
|
|
7
|
+
SINGLE_SELECT = 0,
|
|
8
|
+
MULTI_SELECT = 1,
|
|
9
|
+
ACKNOWLEDGE = 2,
|
|
10
|
+
TOGGLE = 3,
|
|
11
|
+
TEXT = 4,
|
|
12
|
+
OPEN_URL = 5,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface PromptOption {
|
|
16
|
+
readonly displayValue: string;
|
|
17
|
+
readonly returnedValue: ArgumentSingleValueType;
|
|
18
|
+
readonly min?: number;
|
|
19
|
+
readonly max?: number;
|
|
20
|
+
readonly validate?: (
|
|
21
|
+
value: ArgumentSingleValueType,
|
|
22
|
+
) => string | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Prompt {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly promptText: string;
|
|
28
|
+
readonly type: PromptType;
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
readonly defaultOption?: PromptOption;
|
|
31
|
+
readonly options: ReadonlyArray<PromptOption>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PromptResult {
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly value:
|
|
37
|
+
| ArgumentSingleValueType
|
|
38
|
+
| ReadonlyArray<ArgumentSingleValueType>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default interface PrompterService {
|
|
42
|
+
promptEnabled: boolean;
|
|
43
|
+
|
|
44
|
+
prompt(prompt: Prompt): Promise<PromptResult>;
|
|
45
|
+
|
|
46
|
+
promptAll(
|
|
47
|
+
prompts: ReadonlyArray<Prompt>,
|
|
48
|
+
): Promise<ReadonlyArray<PromptResult>>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal service providing secret storage via OS-native credential stores.
|
|
3
|
+
* Not registered in Context -- used internally by {@link DefaultKeyValueService}.
|
|
4
|
+
*/
|
|
5
|
+
export default interface SecretService {
|
|
6
|
+
/**
|
|
7
|
+
* Store a secret value. Constructs the Bun secret name from the current scope and key.
|
|
8
|
+
*
|
|
9
|
+
* @returns the constructed Bun secret name (used as part of the sentinel value in the key-value Map).
|
|
10
|
+
*/
|
|
11
|
+
setSecret(key: string, value: string): Promise<string>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieve a secret value by its full Bun secret name.
|
|
15
|
+
*/
|
|
16
|
+
getSecret(bunSecretName: string): Promise<string | null>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Delete a secret by its full Bun secret name.
|
|
20
|
+
*/
|
|
21
|
+
deleteSecret(bunSecretName: string): Promise<boolean>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Check if a secret exists by its full Bun secret name.
|
|
25
|
+
*/
|
|
26
|
+
hasSecret(bunSecretName: string): Promise<boolean>;
|
|
27
|
+
}
|
|
@@ -6,7 +6,23 @@ export const SHUTDOWN_SERVICE_ID =
|
|
|
6
6
|
*/
|
|
7
7
|
export default interface ShutdownService {
|
|
8
8
|
/**
|
|
9
|
-
* Register a callback
|
|
9
|
+
* Register a callback to be invoked during graceful shutdown.
|
|
10
10
|
*/
|
|
11
11
|
addShutdownListener(callback: () => Promise<void>): void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Enter long-running mode where the first Ctrl-C sets a cooperative flag
|
|
15
|
+
* instead of exiting, and a third Ctrl-C forces exit.
|
|
16
|
+
*/
|
|
17
|
+
enterLongRunningMode(): void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Leave long-running mode, restoring default single Ctrl-C exit behavior.
|
|
21
|
+
*/
|
|
22
|
+
leaveLongRunningMode(): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* True once shutdown has been requested (e.g. first Ctrl-C in long-running mode).
|
|
26
|
+
*/
|
|
27
|
+
readonly isShutdownRequested: boolean;
|
|
12
28
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CellOptions,
|
|
3
|
+
ColumnOptions,
|
|
4
|
+
RowOptions,
|
|
5
|
+
TableOptions,
|
|
6
|
+
} from "./TableGeneratorService.ts";
|
|
7
|
+
|
|
8
|
+
export default class Table {
|
|
9
|
+
readonly rowCount: number;
|
|
10
|
+
readonly columnCount: number;
|
|
11
|
+
readonly options: TableOptions;
|
|
12
|
+
|
|
13
|
+
readonly #columnOptions: Map<number, ColumnOptions> = new Map();
|
|
14
|
+
readonly #rowOptions: Map<number, RowOptions> = new Map();
|
|
15
|
+
readonly #cells: Map<string, { contents: string; options?: CellOptions }> =
|
|
16
|
+
new Map();
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
rowCount: number,
|
|
20
|
+
columnCount: number,
|
|
21
|
+
options?: TableOptions,
|
|
22
|
+
) {
|
|
23
|
+
this.rowCount = rowCount;
|
|
24
|
+
this.columnCount = columnCount;
|
|
25
|
+
this.options = options ?? {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
row(rowIndex: number, rowOptions: RowOptions): Table {
|
|
29
|
+
if (rowIndex < 0 || rowIndex >= this.rowCount) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Row index ${rowIndex} out of bounds [0, ${this.rowCount})`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
this.#rowOptions.set(rowIndex, rowOptions);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
column(columnIndex: number, columnOptions: ColumnOptions): Table {
|
|
39
|
+
if (columnIndex < 0 || columnIndex >= this.columnCount) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Column index ${columnIndex} out of bounds [0, ${this.columnCount})`,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
this.#columnOptions.set(columnIndex, columnOptions);
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
cell(
|
|
49
|
+
rowIndex: number,
|
|
50
|
+
columnIndex: number,
|
|
51
|
+
contents: string,
|
|
52
|
+
cellOptions?: CellOptions,
|
|
53
|
+
): Table {
|
|
54
|
+
if (rowIndex < 0 || rowIndex >= this.rowCount) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Row index ${rowIndex} out of bounds [0, ${this.rowCount})`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
if (columnIndex < 0 || columnIndex >= this.columnCount) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Column index ${columnIndex} out of bounds [0, ${this.columnCount})`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
this.#cells.set(`${rowIndex},${columnIndex}`, {
|
|
65
|
+
contents,
|
|
66
|
+
options: cellOptions,
|
|
67
|
+
});
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getColumnOptions(columnIndex: number): ColumnOptions | undefined {
|
|
72
|
+
return this.#columnOptions.get(columnIndex);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
getRowOptions(rowIndex: number): RowOptions | undefined {
|
|
76
|
+
return this.#rowOptions.get(rowIndex);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getCell(
|
|
80
|
+
rowIndex: number,
|
|
81
|
+
columnIndex: number,
|
|
82
|
+
): { contents: string; options?: CellOptions } | undefined {
|
|
83
|
+
return this.#cells.get(`${rowIndex},${columnIndex}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const TABLE_GENERATOR_SERVICE_ID =
|
|
2
|
+
"@flowscripter/dynamic-cli-framework/table-generator-service";
|
|
3
|
+
|
|
4
|
+
export enum Align {
|
|
5
|
+
LEFT = 0,
|
|
6
|
+
CENTER = 1,
|
|
7
|
+
RIGHT = 2,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface TableOptions {
|
|
11
|
+
border?: boolean;
|
|
12
|
+
borderColor?: string;
|
|
13
|
+
borderBackgroundColor?: string;
|
|
14
|
+
padding?: number;
|
|
15
|
+
maxWidth?: number;
|
|
16
|
+
align?: Align;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ColumnOptions {
|
|
20
|
+
flexWeight?: number;
|
|
21
|
+
minWidth?: number;
|
|
22
|
+
maxWidth?: number;
|
|
23
|
+
align?: Align;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RowOptions {
|
|
27
|
+
align?: Align;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface CellOptions {
|
|
31
|
+
align?: Align;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default interface TableGeneratorService {
|
|
35
|
+
render(table: Table): string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
import type Table from "./Table.ts";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const TREE_PRINTER_SERVICE_ID =
|
|
2
|
+
"@flowscripter/dynamic-cli-framework/tree-printer-service";
|
|
3
|
+
|
|
4
|
+
export interface TreeNode {
|
|
5
|
+
label: string;
|
|
6
|
+
children?: Array<TreeNode | string>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default interface TreePrinterService {
|
|
10
|
+
print(node: TreeNode): string;
|
|
11
|
+
}
|