@flowscripter/dynamic-cli-framework 1.2.2 → 1.3.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 (166) hide show
  1. package/README/core-service-providers.md +2 -2
  2. package/README/development.md +3 -6
  3. package/README/implementation-details.md +17 -17
  4. package/README/key-concepts.md +17 -17
  5. package/README.md +4 -4
  6. package/bun.lock +0 -2
  7. package/index.ts +22 -30
  8. package/package.json +19 -19
  9. package/src/api/argument/Argument.ts +1 -1
  10. package/src/api/argument/ArgumentValueTypes.ts +3 -10
  11. package/src/api/argument/ComplexOption.ts +5 -9
  12. package/src/api/command/GlobalCommand.ts +1 -4
  13. package/src/api/service/core/ArgumentPrompterService.ts +1 -3
  14. package/src/api/service/core/AsciiBannerGeneratorService.ts +1 -4
  15. package/src/api/service/core/CompletionService.ts +2 -6
  16. package/src/api/service/core/ImagePrinterService.ts +1 -2
  17. package/src/api/service/core/KeyValueService.ts +1 -2
  18. package/src/api/service/core/PrettyPrinterService.ts +1 -4
  19. package/src/api/service/core/PrinterService.ts +8 -9
  20. package/src/api/service/core/PrompterService.ts +4 -11
  21. package/src/api/service/core/ShutdownService.ts +1 -2
  22. package/src/api/service/core/SyntaxHighlighterService.ts +1 -5
  23. package/src/api/service/core/Table.ts +7 -25
  24. package/src/api/service/core/TreePrinterService.ts +1 -2
  25. package/src/cli/BaseCLI.ts +17 -47
  26. package/src/cli/DefaultRuntimeCLI.ts +1 -4
  27. package/src/command/CompletionCommand.ts +19 -45
  28. package/src/command/MultiCommandCliHelpCommand.ts +45 -92
  29. package/src/command/SingleCommandCliHelpCommand.ts +17 -28
  30. package/src/command/UsageCommand.ts +6 -12
  31. package/src/command/VersionCommand.ts +2 -6
  32. package/src/launcher.ts +4 -2
  33. package/src/runtime/DefaultContext.ts +2 -5
  34. package/src/runtime/argument/ArgumentTypeGuards.ts +1 -3
  35. package/src/runtime/command/CommandTypeGuards.ts +5 -14
  36. package/src/runtime/command/CommandValidator.ts +56 -118
  37. package/src/runtime/parser.ts +13 -17
  38. package/src/runtime/registry/CommandRegistry.ts +2 -7
  39. package/src/runtime/registry/DefaultCommandRegistry.ts +32 -84
  40. package/src/runtime/registry/DefaultServiceProviderRegistry.ts +3 -9
  41. package/src/runtime/runner.ts +103 -142
  42. package/src/runtime/scanner.ts +28 -46
  43. package/src/runtime/values/ValuePopulationResult.ts +1 -2
  44. package/src/runtime/values/argumentValueMerge.ts +16 -28
  45. package/src/runtime/values/argumentValueValidation.ts +21 -67
  46. package/src/runtime/values/globalCommandValuePopulation.ts +9 -18
  47. package/src/runtime/values/subCommandValuePopulation.ts +42 -65
  48. package/src/service/argumentPrompter/ArgumentPrompterServiceProvider.ts +3 -10
  49. package/src/service/argumentPrompter/DefaultArgumentPrompterService.ts +22 -59
  50. package/src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.ts +5 -14
  51. package/src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.ts +59 -77
  52. package/src/service/banner/BannerServiceProvider.ts +13 -35
  53. package/src/service/banner/command/NoBannerCommand.ts +2 -8
  54. package/src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.ts +5 -10
  55. package/src/service/completion/CompletionServiceProvider.ts +20 -48
  56. package/src/service/completion/DefaultCompletionService.ts +17 -56
  57. package/src/service/completion/shell/ShellHandler.ts +1 -3
  58. package/src/service/completion/shell/fish.ts +1 -1
  59. package/src/service/completion/shell/powershell.ts +2 -12
  60. package/src/service/completion/shell/zsh.ts +1 -1
  61. package/src/service/configuration/ConfigurationServiceProvider.ts +40 -133
  62. package/src/service/configuration/DefaultKeyValueService.ts +6 -20
  63. package/src/service/configuration/DefaultSecretService.ts +10 -14
  64. package/src/service/configuration/command/ConfigCommand.ts +1 -4
  65. package/src/service/configuration/command/DumpConfigCommand.ts +9 -21
  66. package/src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.ts +5 -14
  67. package/src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.ts +5 -12
  68. package/src/service/imagePrinter/DefaultImagePrinterService.ts +1 -5
  69. package/src/service/imagePrinter/ImagePrinterServiceProvider.ts +1 -4
  70. package/src/service/prettyPrinter/DefaultPrettyPrinterService.ts +4 -12
  71. package/src/service/prettyPrinter/PrettyPrinterServiceProvider.ts +3 -10
  72. package/src/service/printer/DefaultPrinterService.ts +20 -83
  73. package/src/service/printer/PrinterServiceProvider.ts +3 -11
  74. package/src/service/printer/command/DarkModeCommand.ts +3 -10
  75. package/src/service/printer/command/LogLevelCommand.ts +7 -26
  76. package/src/service/printer/command/NoColorCommand.ts +3 -10
  77. package/src/service/printer/command/NoHyperlinksCommand.ts +3 -10
  78. package/src/service/printer/terminal/Progress.ts +99 -90
  79. package/src/service/printer/terminal/Spinner.ts +7 -26
  80. package/src/service/prompter/DefaultPrompterService.ts +2 -6
  81. package/src/service/prompter/PrompterServiceProvider.ts +3 -11
  82. package/src/service/prompter/command/NoPromptCommand.ts +3 -10
  83. package/src/service/prompter/prompt/PromptContext.ts +5 -18
  84. package/src/service/prompter/prompt/promptMultiSelect.ts +6 -21
  85. package/src/service/prompter/prompt/promptOpenUrl.ts +7 -22
  86. package/src/service/prompter/prompt/promptSingleSelect.ts +6 -23
  87. package/src/service/prompter/prompt/promptText.ts +10 -27
  88. package/src/service/prompter/prompt/promptToggle.ts +8 -8
  89. package/src/service/shutdown/ShutdownServiceProvider.ts +3 -10
  90. package/src/service/syntaxHighlighter/DefaultSyntaxHighlighterService.ts +13 -26
  91. package/src/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.ts +8 -21
  92. package/src/service/tableGenerator/DefaultTableGeneratorService.ts +44 -68
  93. package/src/service/tableGenerator/TableGeneratorServiceProvider.ts +7 -16
  94. package/src/service/treePrinter/DefaultTreePrinterService.ts +2 -7
  95. package/src/service/treePrinter/TreePrinterServiceProvider.ts +4 -12
  96. package/src/terminal/ImageRenderer.ts +35 -54
  97. package/src/terminal/PngDecoder.ts +10 -19
  98. package/src/terminal/TtyStyler.ts +11 -9
  99. package/src/terminal/TtyTerminal.ts +2 -10
  100. package/src/terminal/supportsHyperlinks.ts +4 -10
  101. package/src/util/configHelper.ts +3 -10
  102. package/src/util/envVarHelper.ts +50 -88
  103. package/src/util/helpHelper.ts +123 -193
  104. package/src/util/logger.ts +12 -42
  105. package/src/util/runnerHelper.ts +20 -61
  106. package/tests/cli/BaseCLI.test.ts +23 -80
  107. package/tests/command/CompletionCommand.test.ts +1 -6
  108. package/tests/command/MultiCommandCliHelpCommand.test.ts +51 -205
  109. package/tests/command/SingleCommandCliHelpCommand.test.ts +21 -103
  110. package/tests/command/UsageCommand.test.ts +4 -10
  111. package/tests/fixtures/Command.ts +87 -68
  112. package/tests/fixtures/CommandRegistry.ts +1 -3
  113. package/tests/fixtures/Context.ts +3 -11
  114. package/tests/fixtures/ServiceProviderRegistry.ts +1 -1
  115. package/tests/fixtures/prettierPluginFoo.ts +1 -1
  116. package/tests/fixtures/util.ts +2 -8
  117. package/tests/runtime/argument/ArgumentTypeGuards.test.ts +1 -3
  118. package/tests/runtime/command/CommandValidator.test.ts +881 -604
  119. package/tests/runtime/parser.test.ts +222 -246
  120. package/tests/runtime/registry/DefaultCommandRegistry.test.ts +15 -37
  121. package/tests/runtime/registry/DefaultServiceProviderRegistry.test.ts +2 -8
  122. package/tests/runtime/runner.test.ts +231 -281
  123. package/tests/runtime/scanner.test.ts +277 -475
  124. package/tests/runtime/values/argumentValueMerge.test.ts +133 -81
  125. package/tests/runtime/values/argumentValueValidation.test.ts +444 -588
  126. package/tests/runtime/values/globalCommandValuePopulation.test.ts +71 -253
  127. package/tests/runtime/values/subCommandValuePopulation.test.ts +1342 -1570
  128. package/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.ts +3 -12
  129. package/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.ts +36 -45
  130. package/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.ts +2 -8
  131. package/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.ts +40 -62
  132. package/tests/service/banner/BannerServiceProvider.test.ts +5 -18
  133. package/tests/service/banner/command/NoBannerCommand.test.ts +1 -4
  134. package/tests/service/completion/CompletionServiceProvider.test.ts +145 -214
  135. package/tests/service/completion/DefaultCompletionService.test.ts +17 -79
  136. package/tests/service/completion/shell/fish.test.ts +1 -3
  137. package/tests/service/configuration/ConfigurationServiceProvider.test.ts +26 -75
  138. package/tests/service/configuration/DefaultKeyValueService.test.ts +9 -21
  139. package/tests/service/configuration/DefaultSecretService.test.ts +7 -15
  140. package/tests/service/configuration/command/DumpConfigCommand.test.ts +4 -13
  141. package/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.ts +6 -12
  142. package/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.ts +1 -10
  143. package/tests/service/imagePrinter/DefaultImagePrinterService.test.ts +5 -70
  144. package/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.ts +4 -11
  145. package/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.ts +2 -6
  146. package/tests/service/printer/DefaultPrinterService.test.ts +57 -255
  147. package/tests/service/printer/PrinterServiceProvider.test.ts +2 -8
  148. package/tests/service/printer/command/DarkModeCommand.test.ts +4 -12
  149. package/tests/service/printer/command/LogLevelCommand.test.ts +4 -17
  150. package/tests/service/printer/command/NoColorCommand.test.ts +4 -12
  151. package/tests/service/printer/command/NoHyperlinksCommand.test.ts +7 -21
  152. package/tests/service/printer/terminal/Progress.test.ts +1 -3
  153. package/tests/service/printer/terminal/Spinner.test.ts +2 -8
  154. package/tests/service/prompter/DefaultPrompterService.test.ts +52 -69
  155. package/tests/service/prompter/PrompterServiceProvider.test.ts +2 -8
  156. package/tests/service/shutdown/ShutdownServiceProvider.test.ts +1 -3
  157. package/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.ts +13 -99
  158. package/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.ts +2 -7
  159. package/tests/service/tableGenerator/DefaultTableGeneratorService.test.ts +12 -33
  160. package/tests/service/tableGenerator/TableGeneratorServiceProvider.test.ts +2 -2
  161. package/tests/service/treePrinter/DefaultTreePrinterService.test.ts +4 -6
  162. package/tests/service/treePrinter/TreePrinterServiceProvider.test.ts +4 -8
  163. package/tests/terminal/ImageRenderer.test.ts +2 -11
  164. package/tests/terminal/PngDecoder.test.ts +2 -6
  165. package/tests/util/configHelper.test.ts +55 -137
  166. package/tests/util/envVarHelper.test.ts +46 -110
@@ -7,10 +7,7 @@ import {
7
7
  getSubCommandWithPositional,
8
8
  } from "../fixtures/Command.ts";
9
9
  import { getContext } from "../fixtures/Context.ts";
10
- import {
11
- expectStringIncludes,
12
- expectStringNotIncludes,
13
- } from "../fixtures/util.ts";
10
+ import { expectStringIncludes, expectStringNotIncludes } from "../fixtures/util.ts";
14
11
  import { ArgumentValueTypeName } from "../../src/api/argument/ArgumentValueTypes.ts";
15
12
  import { SingleCommandCliHelpGlobalCommand } from "../../src/command/SingleCommandCliHelpCommand.ts";
16
13
  import type SubCommand from "../../src/api/command/SubCommand.ts";
@@ -36,13 +33,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
36
33
  const commandRegistry = getCommandRegistry([
37
34
  getGlobalCommand("global1", true, true),
38
35
  getGlobalCommand("global2", true),
39
- getSubCommandWithOption(
40
- "command_a",
41
- true,
42
- true,
43
- true,
44
- ArgumentValueTypeName.BOOLEAN,
45
- ),
36
+ getSubCommandWithOption("command_a", true, true, true, ArgumentValueTypeName.BOOLEAN),
46
37
  getSubCommandWithOption("command_b", true),
47
38
  {
48
39
  name: "topic",
@@ -107,10 +98,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
107
98
  );
108
99
 
109
100
  await help.execute(context);
110
- expectStringIncludes(
111
- streamString.getString(),
112
- "foo --foo <string_value>...",
113
- );
101
+ expectStringIncludes(streamString.getString(), "foo --foo <string_value>...");
114
102
  });
115
103
 
116
104
  test("Ensure single command CLI usage syntax is rendered correctly: simple default command with non-multiple arg", async () => {
@@ -124,10 +112,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
124
112
  );
125
113
 
126
114
  await help.execute(context);
127
- expectStringIncludes(
128
- streamString.getString(),
129
- "foo --foo <string_value>",
130
- );
115
+ expectStringIncludes(streamString.getString(), "foo --foo <string_value>");
131
116
  });
132
117
 
133
118
  test("Ensure single command CLI usage syntax is rendered correctly: simple default command with optional arg", async () => {
@@ -141,10 +126,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
141
126
  );
142
127
 
143
128
  await help.execute(context);
144
- expectStringIncludes(
145
- streamString.getString(),
146
- "foo [--foo <string_value>]",
147
- );
129
+ expectStringIncludes(streamString.getString(), "foo [--foo <string_value>]");
148
130
  });
149
131
 
150
132
  test("Ensure single command CLI usage syntax is rendered correctly: with mandatory arg global modifier", async () => {
@@ -160,18 +142,13 @@ describe("SingleCommandCliHelpCommand tests", () => {
160
142
  );
161
143
 
162
144
  await help.execute(context);
163
- expectStringIncludes(
164
- streamString.getString(),
165
- "foo --foo <string_value>...",
166
- );
145
+ expectStringIncludes(streamString.getString(), "foo --foo <string_value>...");
167
146
  });
168
147
 
169
148
  test("Ensure single command CLI usage syntax is rendered correctly: with global modifier with no arg", async () => {
170
149
  const streamString = new StreamString();
171
150
  const context = getContext(streamString);
172
- const commandRegistry = getCommandRegistry([
173
- getGlobalModifierCommand("modifier1"),
174
- ]);
151
+ const commandRegistry = getCommandRegistry([getGlobalModifierCommand("modifier1")]);
175
152
  const help = new SingleCommandCliHelpGlobalCommand(
176
153
  true,
177
154
  getSubCommandWithOption("command_a", true, true, true),
@@ -179,18 +156,13 @@ describe("SingleCommandCliHelpCommand tests", () => {
179
156
  );
180
157
 
181
158
  await help.execute(context);
182
- expectStringIncludes(
183
- streamString.getString(),
184
- "foo --foo <string_value>...",
185
- );
159
+ expectStringIncludes(streamString.getString(), "foo --foo <string_value>...");
186
160
  });
187
161
 
188
162
  test("Ensure single command CLI usage syntax is rendered correctly: with singular optional arg and global modifier", async () => {
189
163
  const streamString = new StreamString();
190
164
  const context = getContext(streamString);
191
- const commandRegistry = getCommandRegistry([
192
- getGlobalModifierCommand("modifier1"),
193
- ]);
165
+ const commandRegistry = getCommandRegistry([getGlobalModifierCommand("modifier1")]);
194
166
  const help = new SingleCommandCliHelpGlobalCommand(
195
167
  true,
196
168
  getSubCommandWithOption("command_a", true),
@@ -198,10 +170,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
198
170
  );
199
171
 
200
172
  await help.execute(context);
201
- expectStringIncludes(
202
- streamString.getString(),
203
- "foo [--foo <string_value>]",
204
- );
173
+ expectStringIncludes(streamString.getString(), "foo [--foo <string_value>]");
205
174
  });
206
175
 
207
176
  test("Ensure single command CLI usage syntax is rendered correctly: with multiple optional arg and multiple global modifiers and multiple global commands", async () => {
@@ -220,10 +189,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
220
189
  );
221
190
 
222
191
  await help.execute(context);
223
- expectStringIncludes(
224
- streamString.getString(),
225
- "foo [--foo <string_value>]...",
226
- );
192
+ expectStringIncludes(streamString.getString(), "foo [--foo <string_value>]...");
227
193
  });
228
194
 
229
195
  test("Ensure single command CLI usage syntax is rendered correctly: with optional arg, multiple global modifiers, multiple global commands, multiple sub-commands", async () => {
@@ -243,10 +209,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
243
209
  );
244
210
 
245
211
  await help.execute(context);
246
- expectStringIncludes(
247
- streamString.getString(),
248
- "foo [--foo <string_value>]...",
249
- );
212
+ expectStringIncludes(streamString.getString(), "foo [--foo <string_value>]...");
250
213
  });
251
214
 
252
215
  test("Ensure single command CLI usage syntax is rendered correctly: also with boolean args", async () => {
@@ -257,31 +220,16 @@ describe("SingleCommandCliHelpCommand tests", () => {
257
220
  getGlobalModifierCommand("modifier2", "m", true, true),
258
221
  getGlobalCommand("global1", true, true),
259
222
  getGlobalCommand("global2", true, true),
260
- getSubCommandWithOption(
261
- "sub1",
262
- true,
263
- true,
264
- false,
265
- ArgumentValueTypeName.BOOLEAN,
266
- ),
223
+ getSubCommandWithOption("sub1", true, true, false, ArgumentValueTypeName.BOOLEAN),
267
224
  ]);
268
225
  const help = new SingleCommandCliHelpGlobalCommand(
269
226
  true,
270
- getSubCommandWithOption(
271
- "command_a",
272
- true,
273
- false,
274
- true,
275
- ArgumentValueTypeName.BOOLEAN,
276
- ),
227
+ getSubCommandWithOption("command_a", true, false, true, ArgumentValueTypeName.BOOLEAN),
277
228
  commandRegistry,
278
229
  );
279
230
 
280
231
  await help.execute(context);
281
- expectStringIncludes(
282
- streamString.getString(),
283
- "foo [--foo [true|false]]...",
284
- );
232
+ expectStringIncludes(streamString.getString(), "foo [--foo [true|false]]...");
285
233
  });
286
234
 
287
235
  test("Ensure single command CLI usage syntax is rendered correctly: also with default value", async () => {
@@ -290,22 +238,12 @@ describe("SingleCommandCliHelpCommand tests", () => {
290
238
  const commandRegistry = getCommandRegistry();
291
239
  const help = new SingleCommandCliHelpGlobalCommand(
292
240
  true,
293
- getSubCommandWithOption(
294
- "command_a",
295
- true,
296
- false,
297
- true,
298
- ArgumentValueTypeName.STRING,
299
- "foo",
300
- ),
241
+ getSubCommandWithOption("command_a", true, false, true, ArgumentValueTypeName.STRING, "foo"),
301
242
  commandRegistry,
302
243
  );
303
244
 
304
245
  await help.execute(context);
305
- expectStringIncludes(
306
- streamString.getString(),
307
- "foo [--foo <string_value>]...",
308
- );
246
+ expectStringIncludes(streamString.getString(), "foo [--foo <string_value>]...");
309
247
  });
310
248
 
311
249
  test("Ensure single command CLI usage syntax is rendered correctly: with positionals", async () => {
@@ -331,12 +269,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
331
269
 
332
270
  help = new SingleCommandCliHelpGlobalCommand(
333
271
  true,
334
- getSubCommandWithPositional(
335
- "command_a",
336
- true,
337
- true,
338
- ArgumentValueTypeName.BOOLEAN,
339
- ),
272
+ getSubCommandWithPositional("command_a", true, true, ArgumentValueTypeName.BOOLEAN),
340
273
  commandRegistry,
341
274
  );
342
275
  await help.execute(context);
@@ -344,12 +277,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
344
277
 
345
278
  help = new SingleCommandCliHelpGlobalCommand(
346
279
  true,
347
- getSubCommandWithPositional(
348
- "command_a",
349
- true,
350
- true,
351
- ArgumentValueTypeName.STRING,
352
- ),
280
+ getSubCommandWithPositional("command_a", true, true, ArgumentValueTypeName.STRING),
353
281
  commandRegistry,
354
282
  );
355
283
  await help.execute(context);
@@ -357,12 +285,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
357
285
 
358
286
  help = new SingleCommandCliHelpGlobalCommand(
359
287
  true,
360
- getSubCommandWithPositional(
361
- "command_a",
362
- false,
363
- false,
364
- ArgumentValueTypeName.STRING,
365
- ),
288
+ getSubCommandWithPositional("command_a", false, false, ArgumentValueTypeName.STRING),
366
289
  commandRegistry,
367
290
  );
368
291
  await help.execute(context);
@@ -370,12 +293,7 @@ describe("SingleCommandCliHelpCommand tests", () => {
370
293
 
371
294
  help = new SingleCommandCliHelpGlobalCommand(
372
295
  true,
373
- getSubCommandWithPositional(
374
- "command_a",
375
- false,
376
- true,
377
- ArgumentValueTypeName.BOOLEAN,
378
- ),
296
+ getSubCommandWithPositional("command_a", false, true, ArgumentValueTypeName.BOOLEAN),
379
297
  commandRegistry,
380
298
  );
381
299
  await help.execute(context);
@@ -32,23 +32,17 @@ describe("UsageCommand tests", () => {
32
32
  context.addServiceInstance(PRINTER_SERVICE_ID, printer);
33
33
 
34
34
  const usageCommand = new UsageCommand(
35
- new class implements Command {
35
+ new (class implements Command {
36
36
  readonly name = "help";
37
37
 
38
- execute(
39
- _argumentValues: ArgumentValues,
40
- _context: Context,
41
- ): Promise<void> {
38
+ execute(_argumentValues: ArgumentValues, _context: Context): Promise<void> {
42
39
  return Promise.resolve(undefined);
43
40
  }
44
- }(),
41
+ })(),
45
42
  );
46
43
 
47
44
  await usageCommand.execute(context);
48
45
 
49
- expectStringEquals(
50
- dummyStdout.getString(),
51
- "Try running:\n\n foo --help\n\n",
52
- );
46
+ expectStringEquals(dummyStdout.getString(), "Try running:\n\n foo --help\n\n");
53
47
  });
54
48
  });
@@ -34,9 +34,9 @@ export function getGlobalModifierCommand(
34
34
  executePriority: 1,
35
35
  argument: withArg
36
36
  ? {
37
- type: ArgumentValueTypeName.STRING,
38
- isOptional: !mandatoryArg,
39
- }
37
+ type: ArgumentValueTypeName.STRING,
38
+ isOptional: !mandatoryArg,
39
+ }
40
40
  : undefined,
41
41
  execute: async (): Promise<void> => {},
42
42
  };
@@ -71,10 +71,10 @@ export function getGlobalCommand(
71
71
  enableConfiguration,
72
72
  argument: withArg
73
73
  ? {
74
- type: ArgumentValueTypeName.STRING,
75
- isOptional: !mandatoryArg,
76
- configurationKey,
77
- }
74
+ type: ArgumentValueTypeName.STRING,
75
+ isOptional: !mandatoryArg,
76
+ configurationKey,
77
+ }
78
78
  : undefined,
79
79
  execute: async (): Promise<void> => {},
80
80
  };
@@ -96,15 +96,19 @@ export function getGlobalCommandWithShortAlias(
96
96
  export function getSubCommandWithOptionAndPositional(): SubCommand {
97
97
  return {
98
98
  name: "subCommand",
99
- options: [{
100
- name: "goo",
101
- shortAlias: "g",
102
- type: ArgumentValueTypeName.STRING,
103
- }],
104
- positionals: [{
105
- name: "foo",
106
- type: ArgumentValueTypeName.STRING,
107
- }],
99
+ options: [
100
+ {
101
+ name: "goo",
102
+ shortAlias: "g",
103
+ type: ArgumentValueTypeName.STRING,
104
+ },
105
+ ],
106
+ positionals: [
107
+ {
108
+ name: "foo",
109
+ type: ArgumentValueTypeName.STRING,
110
+ },
111
+ ],
108
112
  execute: async (): Promise<void> => {},
109
113
  };
110
114
  }
@@ -139,14 +143,16 @@ export function getSubCommandWithOption(
139
143
  description: "good",
140
144
  enableConfiguration,
141
145
  options: withArg
142
- ? [{
143
- name: "foo",
144
- type,
145
- isOptional: !mandatoryArg,
146
- isArray: multiple,
147
- defaultValue,
148
- configurationKey,
149
- }]
146
+ ? [
147
+ {
148
+ name: "foo",
149
+ type,
150
+ isOptional: !mandatoryArg,
151
+ isArray: multiple,
152
+ defaultValue,
153
+ configurationKey,
154
+ },
155
+ ]
150
156
  : [],
151
157
  positionals: [],
152
158
  execute: async (): Promise<void> => {},
@@ -166,13 +172,15 @@ export function getSubCommandWithPositional(
166
172
  description: "good",
167
173
  enableConfiguration,
168
174
  options: [],
169
- positionals: [{
170
- name: "foo",
171
- type,
172
- isVarargOptional: optional,
173
- isVarargMultiple: multiple,
174
- configurationKey,
175
- }],
175
+ positionals: [
176
+ {
177
+ name: "foo",
178
+ type,
179
+ isVarargOptional: optional,
180
+ isVarargMultiple: multiple,
181
+ configurationKey,
182
+ },
183
+ ],
176
184
  execute: async (): Promise<void> => {},
177
185
  };
178
186
  }
@@ -185,44 +193,55 @@ export function getSubCommandWithComplexOptions(
185
193
  return {
186
194
  name: "subCommand",
187
195
  enableConfiguration,
188
- options: [{
189
- name: "alpha",
190
- shortAlias: "a",
191
- type: ComplexValueTypeName.COMPLEX,
192
- isArray: true,
193
- properties: [{
194
- name: "beta",
195
- shortAlias: "b",
196
+ options: [
197
+ {
198
+ name: "alpha",
199
+ shortAlias: "a",
196
200
  type: ComplexValueTypeName.COMPLEX,
197
- isArray: betaIsArray,
198
- properties: [{
199
- name: "gamma",
200
- shortAlias: "g",
201
- type: ArgumentValueTypeName.STRING,
202
- }, {
203
- name: "delta",
204
- shortAlias: "d",
205
- type: ArgumentValueTypeName.NUMBER,
206
- isArray: true,
207
- }],
208
- }],
209
- }, {
210
- name: "epsilon",
211
- shortAlias: "e",
212
- type: ComplexValueTypeName.COMPLEX,
213
- properties: [{
214
- name: "gamma",
215
- shortAlias: "g",
216
- type: ArgumentValueTypeName.STRING,
217
- configurationKey: "FOO_BAR_A",
218
- }, {
219
- name: "delta",
220
- shortAlias: "d",
221
- type: ArgumentValueTypeName.NUMBER,
222
- configurationKey: "FOO_BAR_B",
223
- isArray: deltaIsArray,
224
- }],
225
- }],
201
+ isArray: true,
202
+ properties: [
203
+ {
204
+ name: "beta",
205
+ shortAlias: "b",
206
+ type: ComplexValueTypeName.COMPLEX,
207
+ isArray: betaIsArray,
208
+ properties: [
209
+ {
210
+ name: "gamma",
211
+ shortAlias: "g",
212
+ type: ArgumentValueTypeName.STRING,
213
+ },
214
+ {
215
+ name: "delta",
216
+ shortAlias: "d",
217
+ type: ArgumentValueTypeName.NUMBER,
218
+ isArray: true,
219
+ },
220
+ ],
221
+ },
222
+ ],
223
+ },
224
+ {
225
+ name: "epsilon",
226
+ shortAlias: "e",
227
+ type: ComplexValueTypeName.COMPLEX,
228
+ properties: [
229
+ {
230
+ name: "gamma",
231
+ shortAlias: "g",
232
+ type: ArgumentValueTypeName.STRING,
233
+ configurationKey: "FOO_BAR_A",
234
+ },
235
+ {
236
+ name: "delta",
237
+ shortAlias: "d",
238
+ type: ArgumentValueTypeName.NUMBER,
239
+ configurationKey: "FOO_BAR_B",
240
+ isArray: deltaIsArray,
241
+ },
242
+ ],
243
+ },
244
+ ],
226
245
  positionals: [],
227
246
  execute: async (): Promise<void> => {},
228
247
  };
@@ -1,8 +1,6 @@
1
1
  import DefaultCommandRegistry from "../../src/runtime/registry/DefaultCommandRegistry.ts";
2
2
  import type Command from "../../src/api/command/Command.ts";
3
3
 
4
- export function getCommandRegistry(
5
- commands?: Array<Command>,
6
- ): DefaultCommandRegistry {
4
+ export function getCommandRegistry(commands?: Array<Command>): DefaultCommandRegistry {
7
5
  return new DefaultCommandRegistry(commands);
8
6
  }
@@ -11,9 +11,7 @@ import TtyStyler from "../../src/terminal/TtyStyler.ts";
11
11
  import { TABLE_GENERATOR_SERVICE_ID } from "../../src/api/service/core/TableGeneratorService.ts";
12
12
  import DefaultTableGeneratorService from "../../src/service/tableGenerator/DefaultTableGeneratorService.ts";
13
13
 
14
- export function getContext(
15
- streamString: WritableStreamString,
16
- ): Context {
14
+ export function getContext(streamString: WritableStreamString): Context {
17
15
  const defaultContext = new DefaultContext(getCLIConfig());
18
16
  const defaultPrinterService = new DefaultPrinterService(
19
17
  streamString.writableStream,
@@ -27,14 +25,8 @@ export function getContext(
27
25
 
28
26
  defaultPrinterService.colorEnabled = false;
29
27
  defaultContext.addServiceInstance(PRINTER_SERVICE_ID, defaultPrinterService);
30
- defaultContext.addServiceInstance(
31
- KEY_VALUE_SERVICE_ID,
32
- new DefaultKeyValueService(),
33
- );
34
- defaultContext.addServiceInstance(
35
- TABLE_GENERATOR_SERVICE_ID,
36
- new DefaultTableGeneratorService(),
37
- );
28
+ defaultContext.addServiceInstance(KEY_VALUE_SERVICE_ID, new DefaultKeyValueService());
29
+ defaultContext.addServiceInstance(TABLE_GENERATOR_SERVICE_ID, new DefaultTableGeneratorService());
38
30
 
39
31
  return defaultContext;
40
32
  }
@@ -9,7 +9,7 @@ export function getServiceProviderRegistry(
9
9
 
10
10
  if (serviceProviders) {
11
11
  serviceProviders.forEach((serviceProvider) =>
12
- serviceProviderRegistry.addServiceProvider(serviceProvider)
12
+ serviceProviderRegistry.addServiceProvider(serviceProvider),
13
13
  );
14
14
  }
15
15
  return serviceProviderRegistry;
@@ -17,7 +17,7 @@ const parsers: Record<string, Parser> = {
17
17
  };
18
18
 
19
19
  const printers: Record<string, Printer> = {
20
- "foo": {
20
+ foo: {
21
21
  print: () => "foo",
22
22
  },
23
23
  };
@@ -8,10 +8,7 @@ export function expectStringIncludes(actual: string, expected: string) {
8
8
  expect(stripVTControlCharacters(actual).includes(expected)).toBeTrue();
9
9
  }
10
10
 
11
- export function expectStringNotIncludes(
12
- actual: string,
13
- expected: string,
14
- ) {
11
+ export function expectStringNotIncludes(actual: string, expected: string) {
15
12
  expect(stripVTControlCharacters(actual).includes(expected)).toBeFalse();
16
13
  }
17
14
 
@@ -27,10 +24,7 @@ export function sleep(ms: number) {
27
24
  return new Promise((resolve) => setTimeout(resolve, ms));
28
25
  }
29
26
 
30
- export async function write(
31
- writableStream: WritableStream,
32
- message: string,
33
- ) {
27
+ export async function write(writableStream: WritableStream, message: string) {
34
28
  const encoded = encoder.encode(message);
35
29
  const writer = writableStream.getWriter();
36
30
 
@@ -13,9 +13,7 @@ function getComplexOption(): ComplexOption {
13
13
  return {
14
14
  name: "option",
15
15
  type: ComplexValueTypeName.COMPLEX,
16
- properties: [
17
- getOption(),
18
- ],
16
+ properties: [getOption()],
19
17
  };
20
18
  }
21
19