@flowscripter/dynamic-cli-framework 1.1.6 → 1.2.1

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.
Files changed (160) hide show
  1. package/.github/workflows/release-bun-library.yml +1 -0
  2. package/README/core-commands.md +40 -0
  3. package/README/core-service-providers.md +198 -0
  4. package/README/development.md +60 -0
  5. package/README/implementation-details.md +474 -0
  6. package/README/key-concepts.md +751 -0
  7. package/README.md +12 -1413
  8. package/bun.lock +22 -18
  9. package/index.ts +97 -1
  10. package/package.json +8 -7
  11. package/src/api/BaseCLIFeatureOptions.ts +10 -0
  12. package/src/api/CLIConfig.ts +5 -0
  13. package/src/api/RunResult.ts +16 -0
  14. package/src/api/argument/Argument.ts +24 -0
  15. package/src/api/service/ServiceProvider.ts +3 -3
  16. package/src/api/service/core/ArgumentPrompterService.ts +10 -0
  17. package/src/api/service/core/AsciiBannerGeneratorService.ts +44 -7
  18. package/src/api/service/core/CompletionService.ts +36 -0
  19. package/src/api/service/core/DataDumpGeneratorService.ts +27 -0
  20. package/src/api/service/core/ImagePrinterService.ts +26 -0
  21. package/src/api/service/core/KeyValueService.ts +22 -5
  22. package/src/api/service/core/PrinterService.ts +127 -1
  23. package/src/api/service/core/PrompterService.ts +49 -0
  24. package/src/api/service/core/SecretService.ts +27 -0
  25. package/src/api/service/core/ShutdownService.ts +17 -1
  26. package/src/api/service/core/Table.ts +85 -0
  27. package/src/api/service/core/TableGeneratorService.ts +38 -0
  28. package/src/api/service/core/TreePrinterService.ts +11 -0
  29. package/src/cli/BaseCLI.ts +116 -44
  30. package/src/cli/DefaultRuntimeCLI.ts +10 -18
  31. package/src/command/CompletionCommand.ts +179 -0
  32. package/src/command/MultiCommandCliHelpCommand.ts +18 -2
  33. package/src/command/SingleCommandCliHelpCommand.ts +10 -1
  34. package/src/launcher.ts +16 -58
  35. package/src/runtime/command/CommandValidator.ts +3 -3
  36. package/src/runtime/runner.ts +102 -30
  37. package/src/runtime/scanner.ts +18 -15
  38. package/src/runtime/values/argumentValueValidation.ts +49 -5
  39. package/src/runtime/values/globalCommandValuePopulation.ts +1 -1
  40. package/src/runtime/values/subCommandValuePopulation.ts +9 -8
  41. package/src/service/argumentPrompter/ArgumentPrompterServiceProvider.ts +34 -0
  42. package/src/service/argumentPrompter/DefaultArgumentPrompterService.ts +330 -0
  43. package/src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.ts +1 -1
  44. package/src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.ts +254 -17
  45. package/src/service/banner/BannerServiceProvider.ts +2 -2
  46. package/src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.ts +85 -0
  47. package/src/service/chiselAsciiBannerGenerator/chisel.flf.json +3 -0
  48. package/src/service/completion/CompletionServiceProvider.ts +212 -0
  49. package/src/service/completion/DefaultCompletionService.ts +364 -0
  50. package/src/service/completion/shell/ShellHandler.ts +16 -0
  51. package/src/service/completion/shell/bash.ts +47 -0
  52. package/src/service/completion/shell/fish.ts +43 -0
  53. package/src/service/completion/shell/powershell.ts +66 -0
  54. package/src/service/completion/shell/zsh.ts +50 -0
  55. package/src/service/configuration/ConfigurationServiceProvider.ts +138 -42
  56. package/src/service/configuration/DefaultKeyValueService.ts +53 -7
  57. package/src/service/configuration/DefaultSecretService.ts +85 -0
  58. package/src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.ts +41 -0
  59. package/src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.ts +80 -0
  60. package/src/service/imagePrinter/DefaultImagePrinterService.ts +23 -0
  61. package/src/service/imagePrinter/ImagePrinterServiceProvider.ts +32 -0
  62. package/src/service/prettyPrinter/PrettyPrinterServiceProvider.ts +1 -1
  63. package/src/service/printer/DefaultPrinterService.ts +147 -27
  64. package/src/service/printer/PrinterServiceProvider.ts +7 -7
  65. package/src/service/printer/command/NoHyperlinksCommand.ts +40 -0
  66. package/src/service/printer/terminal/Progress.ts +21 -4
  67. package/src/service/printer/terminal/Spinner.ts +32 -8
  68. package/src/service/printer/terminal/Theme.ts +1 -1
  69. package/src/service/prompter/DefaultPrompterService.ts +87 -0
  70. package/src/service/prompter/PrompterServiceProvider.ts +36 -0
  71. package/src/service/prompter/command/NoPromptCommand.ts +40 -0
  72. package/src/service/prompter/prompt/PromptContext.ts +47 -0
  73. package/src/service/prompter/prompt/promptAcknowledge.ts +28 -0
  74. package/src/service/prompter/prompt/promptMultiSelect.ts +99 -0
  75. package/src/service/prompter/prompt/promptOpenUrl.ts +97 -0
  76. package/src/service/prompter/prompt/promptSingleSelect.ts +102 -0
  77. package/src/service/prompter/prompt/promptText.ts +107 -0
  78. package/src/service/prompter/prompt/promptToggle.ts +28 -0
  79. package/src/service/shutdown/DefaultShutdownService.ts +13 -0
  80. package/src/service/shutdown/ShutdownServiceProvider.ts +28 -9
  81. package/src/service/shutdown/ShutdownState.ts +5 -0
  82. package/src/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.ts +1 -1
  83. package/src/service/tableGenerator/DefaultTableGeneratorService.ts +415 -0
  84. package/src/service/tableGenerator/TableGeneratorServiceProvider.ts +43 -0
  85. package/src/service/treePrinter/DefaultTreePrinterService.ts +49 -0
  86. package/src/service/treePrinter/TreePrinterServiceProvider.ts +40 -0
  87. package/src/terminal/Ansi.ts +27 -0
  88. package/src/terminal/ImageRenderer.ts +199 -0
  89. package/src/terminal/KeyReader.ts +23 -0
  90. package/src/terminal/PngDecoder.ts +143 -0
  91. package/src/{service/printer/terminal → terminal}/Styler.ts +3 -0
  92. package/src/{service/printer/terminal → terminal}/Terminal.ts +1 -0
  93. package/src/terminal/TtyKeyReader.ts +83 -0
  94. package/src/terminal/TtyStyler.ts +78 -0
  95. package/src/{service/printer/terminal → terminal}/TtyTerminal.ts +9 -1
  96. package/src/terminal/supportsHyperlinks.ts +110 -0
  97. package/src/util/configHelper.ts +2 -2
  98. package/src/util/envVarHelper.ts +2 -2
  99. package/src/util/helpHelper.ts +66 -122
  100. package/src/util/logger.ts +16 -14
  101. package/src/util/runnerHelper.ts +1 -1
  102. package/tests/cli/BaseCLI.test.ts +50 -54
  103. package/tests/command/CompletionCommand.test.ts +68 -0
  104. package/tests/command/UsageCommand.test.ts +3 -2
  105. package/tests/command/VersionCommand.test.ts +3 -2
  106. package/tests/fixtures/Context.ts +9 -2
  107. package/tests/fixtures/util.ts +1 -1
  108. package/tests/runtime/parser.test.ts +9 -7
  109. package/tests/runtime/registry/DefaultServiceProviderRegistry.test.ts +3 -3
  110. package/tests/runtime/values/argumentValueValidation.test.ts +193 -0
  111. package/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.ts +47 -0
  112. package/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.ts +754 -0
  113. package/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.ts +5 -4
  114. package/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.ts +163 -3
  115. package/tests/service/asciiBannerGenerator/__snapshots__/DefaultAsciiBannerGeneratorService.test.ts.snap +1 -1
  116. package/tests/service/banner/BannerServiceProvider.test.ts +8 -4
  117. package/tests/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.test.ts +52 -0
  118. package/tests/service/completion/CompletionServiceProvider.test.ts +404 -0
  119. package/tests/service/completion/DefaultCompletionService.test.ts +278 -0
  120. package/tests/service/completion/shell/bash.test.ts +73 -0
  121. package/tests/service/completion/shell/fish.test.ts +62 -0
  122. package/tests/service/completion/shell/powershell.test.ts +59 -0
  123. package/tests/service/completion/shell/zsh.test.ts +60 -0
  124. package/tests/service/configuration/ConfigurationServiceProvider.test.ts +24 -12
  125. package/tests/service/configuration/DefaultKeyValueService.test.ts +118 -16
  126. package/tests/service/configuration/DefaultSecretService.test.ts +148 -0
  127. package/tests/service/configuration/command/ConfigCommand.test.ts +29 -0
  128. package/tests/service/configuration/command/DumpConfigCommand.test.ts +60 -0
  129. package/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.ts +57 -0
  130. package/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.ts +217 -0
  131. package/tests/service/imagePrinter/DefaultImagePrinterService.test.ts +96 -0
  132. package/tests/service/imagePrinter/ImagePrinterServiceProvider.test.ts +17 -0
  133. package/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.ts +2 -2
  134. package/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.ts +5 -4
  135. package/tests/service/printer/DefaultPrinterService.test.ts +233 -2
  136. package/tests/service/printer/PrinterServiceProvider.test.ts +6 -5
  137. package/tests/service/printer/command/DarkModeCommand.test.ts +83 -0
  138. package/tests/service/printer/command/LogLevelCommand.test.ts +7 -5
  139. package/tests/service/printer/command/NoColorCommand.test.ts +83 -0
  140. package/tests/service/printer/command/NoHyperlinksCommand.test.ts +89 -0
  141. package/tests/service/printer/terminal/Progress.test.ts +64 -4
  142. package/tests/service/printer/terminal/Spinner.test.ts +44 -3
  143. package/tests/service/prompter/DefaultPrompterService.test.ts +615 -0
  144. package/tests/service/prompter/PrompterServiceProvider.test.ts +47 -0
  145. package/tests/service/prompter/command/NoPromptCommand.test.ts +58 -0
  146. package/tests/service/shutdown/ShutdownServiceProvider.test.ts +4 -2
  147. package/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.ts +3 -2
  148. package/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.ts +5 -4
  149. package/tests/service/tableGenerator/DefaultTableGeneratorService.test.ts +363 -0
  150. package/tests/service/tableGenerator/TableGeneratorServiceProvider.test.ts +47 -0
  151. package/tests/service/treePrinter/DefaultTreePrinterService.test.ts +144 -0
  152. package/tests/service/treePrinter/TreePrinterServiceProvider.test.ts +55 -0
  153. package/tests/terminal/ImageRenderer.test.ts +161 -0
  154. package/tests/terminal/PngDecoder.test.ts +223 -0
  155. package/tests/terminal/supportsHyperlinks.test.ts +149 -0
  156. package/tests/util/configHelper.test.ts +4 -4
  157. package/tests/util/logger.test.ts +23 -1
  158. package/tsconfig.json +31 -0
  159. package/src/service/printer/terminal/Ansi.ts +0 -10
  160. package/src/service/printer/terminal/TtyStyler.ts +0 -39
@@ -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 method for CLI shutdown.
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
+ }