@flowscripter/dynamic-cli-framework 1.2.1 → 1.3.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.
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
@@ -1,28 +1,17 @@
1
1
  import type PrinterService from "../api/service/core/PrinterService.ts";
2
- import {
3
- Icon,
4
- PRINTER_SERVICE_ID,
5
- } from "../api/service/core/PrinterService.ts";
2
+ import { Icon, PRINTER_SERVICE_ID } from "../api/service/core/PrinterService.ts";
6
3
  import type { ParseResult } from "../runtime/parser.ts";
7
- import {
8
- isGlobalCommand,
9
- isGlobalModifierCommand,
10
- } from "../runtime/command/CommandTypeGuards.ts";
4
+ import { isGlobalCommand, isGlobalModifierCommand } from "../runtime/command/CommandTypeGuards.ts";
11
5
  import type Context from "../api/Context.ts";
12
6
  import { getInvalidArgumentString } from "../runtime/values/argumentValueValidation.ts";
13
7
  import type CommandRegistry from "../runtime/registry/CommandRegistry.ts";
14
8
  import { findPossibleCommandNames } from "./helpHelper.ts";
15
9
 
16
- function getCommandString(
17
- printerService: PrinterService,
18
- parseResult: ParseResult,
19
- ): string {
10
+ function getCommandString(printerService: PrinterService, parseResult: ParseResult): string {
20
11
  const { command, groupCommand } = parseResult;
21
12
 
22
13
  if (groupCommand) {
23
- return printerService.yellow(
24
- `'${groupCommand.name}:${command.name}'`,
25
- );
14
+ return printerService.yellow(`'${groupCommand.name}:${command.name}'`);
26
15
  }
27
16
  return printerService.yellow(`'${command.name}'`);
28
17
  }
@@ -32,29 +21,21 @@ export async function printParseResultError(
32
21
  parseResult: ParseResult,
33
22
  isDefaultCommand = false,
34
23
  ) {
35
- const printerService = context.getServiceById(
36
- PRINTER_SERVICE_ID,
37
- ) as PrinterService;
24
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
38
25
  const commandErrorString = isDefaultCommand
39
26
  ? "Parse error: "
40
- : `Parse error for command: ${
41
- getCommandString(printerService, parseResult)
42
- }`;
27
+ : `Parse error for command: ${getCommandString(printerService, parseResult)}`;
43
28
  const { command, invalidArguments } = parseResult;
44
29
 
45
30
  let errorString = "=> ";
46
31
 
47
- const skipArgName = isGlobalModifierCommand(command) ||
48
- isGlobalCommand(command);
49
- const argsString = invalidArguments.map(
50
- (arg) => getInvalidArgumentString(arg, skipArgName),
51
- ).join(", ");
32
+ const skipArgName = isGlobalModifierCommand(command) || isGlobalCommand(command);
33
+ const argsString = invalidArguments
34
+ .map((arg) => getInvalidArgumentString(arg, skipArgName))
35
+ .join(", ");
52
36
  errorString = `${errorString}${printerService.yellow(argsString)}`;
53
37
 
54
- await printerService.error(
55
- `${commandErrorString}\n ${errorString}\n\n`,
56
- Icon.FAILURE,
57
- );
38
+ await printerService.error(`${commandErrorString}\n ${errorString}\n\n`, Icon.FAILURE);
58
39
  }
59
40
 
60
41
  export async function printCommandExecutionError(
@@ -63,14 +44,10 @@ export async function printCommandExecutionError(
63
44
  err: Error,
64
45
  isDefaultCommand = false,
65
46
  ) {
66
- const printerService = context.getServiceById(
67
- PRINTER_SERVICE_ID,
68
- ) as PrinterService;
47
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
69
48
  const commandErrorString = isDefaultCommand
70
49
  ? "Execution error: "
71
- : `Execution error for command: ${
72
- getCommandString(printerService, parseResult)
73
- }`;
50
+ : `Execution error for command: ${getCommandString(printerService, parseResult)}`;
74
51
  if (err !== undefined) {
75
52
  await printerService.error(
76
53
  `${commandErrorString}\n => ${printerService.yellow(err.message)}\n\n`,
@@ -78,18 +55,14 @@ export async function printCommandExecutionError(
78
55
  );
79
56
  } else {
80
57
  await printerService.error(
81
- `${commandErrorString}\n => ${
82
- printerService.yellow("error is undefined")
83
- }\n\n`,
58
+ `${commandErrorString}\n => ${printerService.yellow("error is undefined")}\n\n`,
84
59
  Icon.FAILURE,
85
60
  );
86
61
  }
87
62
  }
88
63
 
89
64
  export async function printNoCommandSpecifiedError(context: Context) {
90
- const printerService = context.getServiceById(
91
- PRINTER_SERVICE_ID,
92
- ) as PrinterService;
65
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
93
66
  await printerService.error("No command specified\n\n");
94
67
  }
95
68
 
@@ -98,9 +71,7 @@ export async function printNoCommandRecognisedError(
98
71
  commandRegistry: CommandRegistry,
99
72
  availableArgs: ReadonlyArray<string>,
100
73
  ) {
101
- const printerService = context.getServiceById(
102
- PRINTER_SERVICE_ID,
103
- ) as PrinterService;
74
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
104
75
  await printerService.error("No command recognised\n\n");
105
76
 
106
77
  if (availableArgs.length > 0) {
@@ -110,11 +81,7 @@ export async function printNoCommandRecognisedError(
110
81
  const allPossibleCommandNames: string[] = [];
111
82
  for (const arg of availableArgs) {
112
83
  // look for other possible matches
113
- const possibleCommandNames = findPossibleCommandNames(
114
- arg,
115
- groupCommands,
116
- subCommands,
117
- );
84
+ const possibleCommandNames = findPossibleCommandNames(arg, groupCommands, subCommands);
118
85
  // add the possible command names to the list if not already present
119
86
  for (const possibleCommandName of possibleCommandNames) {
120
87
  if (!allPossibleCommandNames.includes(possibleCommandName)) {
@@ -136,18 +103,10 @@ export async function printUnusedArgsWarning(
136
103
  context: Context,
137
104
  overallUnusedArgs: ReadonlyArray<string>,
138
105
  ) {
139
- const printerService = context.getServiceById(
140
- PRINTER_SERVICE_ID,
141
- ) as PrinterService;
106
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
142
107
  if (overallUnusedArgs.length === 1) {
143
- await printerService.warn(
144
- `Unused arg: ${overallUnusedArgs[0]}\n\n`,
145
- Icon.ALERT,
146
- );
108
+ await printerService.warn(`Unused arg: ${overallUnusedArgs[0]}\n\n`, Icon.ALERT);
147
109
  } else {
148
- await printerService.warn(
149
- `Unused args: ${overallUnusedArgs.join(" ")}\n\n`,
150
- Icon.ALERT,
151
- );
110
+ await printerService.warn(`Unused args: ${overallUnusedArgs.join(" ")}\n\n`, Icon.ALERT);
152
111
  }
153
112
  }
@@ -12,13 +12,8 @@ import { RunState } from "../../src/api/RunResult.ts";
12
12
  import { ArgumentValueTypeName } from "../../src/api/argument/ArgumentValueTypes.ts";
13
13
  import BaseCLI from "../../src/cli/BaseCLI.ts";
14
14
  import type KeyValueService from "../../src/api/service/core/KeyValueService.ts";
15
- import {
16
- KEY_VALUE_SERVICE_ID,
17
- } from "../../src/api/service/core/KeyValueService.ts";
18
- import type {
19
- ServiceInfo,
20
- ServiceProvider,
21
- } from "../../src/api/service/ServiceProvider.ts";
15
+ import { KEY_VALUE_SERVICE_ID } from "../../src/api/service/core/KeyValueService.ts";
16
+ import type { ServiceInfo, ServiceProvider } from "../../src/api/service/ServiceProvider.ts";
22
17
  import type Context from "../../src/api/Context.ts";
23
18
  import type CLIConfig from "../../src/api/CLIConfig.ts";
24
19
  import StreamString from "../fixtures/StreamString.ts";
@@ -76,14 +71,9 @@ describe("BaseCLI tests", () => {
76
71
  let modifierHasRun = false;
77
72
  let subHasRun = false;
78
73
 
79
- const modifierCommand = getGlobalModifierCommandWithArgument(
80
- "modifier",
81
- "m",
82
- 1,
83
- {
84
- type: ArgumentValueTypeName.STRING,
85
- },
86
- );
74
+ const modifierCommand = getGlobalModifierCommandWithArgument("modifier", "m", 1, {
75
+ type: ArgumentValueTypeName.STRING,
76
+ });
87
77
  const option = {
88
78
  name: "foo",
89
79
  type: ArgumentValueTypeName.STRING,
@@ -103,13 +93,7 @@ describe("BaseCLI tests", () => {
103
93
  baseCLI.addCommand(modifierCommand);
104
94
  baseCLI.addCommand(subCommand);
105
95
 
106
- const runResult = await baseCLI.run([
107
- "unused",
108
- "--modifier=bar",
109
- "command",
110
- "--foo",
111
- "bar",
112
- ]);
96
+ const runResult = await baseCLI.run(["unused", "--modifier=bar", "command", "--foo", "bar"]);
113
97
 
114
98
  expect(runResult.runState).toEqual(RunState.SUCCESS);
115
99
  expect(modifierHasRun).toBeTrue();
@@ -158,24 +142,13 @@ describe("BaseCLI tests", () => {
158
142
 
159
143
  async serviceMethod(context: Context): Promise<void> {
160
144
  expect(await this.copyOfKeyValueService!.hasKey("name")).toBeTrue();
161
- expect(
162
- await this.copyOfKeyValueService!.getKey("name"),
163
- ).toEqual(
164
- "modifierCommand",
165
- );
166
- await this.copyOfKeyValueService!.setKey(
167
- "name",
168
- "defaultService1+modifierCommand",
169
- );
145
+ expect(await this.copyOfKeyValueService!.getKey("name")).toEqual("modifierCommand");
146
+ await this.copyOfKeyValueService!.setKey("name", "defaultService1+modifierCommand");
170
147
 
171
- const keyValueService = context.getServiceById(
172
- KEY_VALUE_SERVICE_ID,
173
- ) as KeyValueService;
148
+ const keyValueService = context.getServiceById(KEY_VALUE_SERVICE_ID) as KeyValueService;
174
149
 
175
150
  expect(await keyValueService.hasKey("name")).toBeTrue();
176
- expect(
177
- await this.copyOfKeyValueService!.getKey("name"),
178
- ).toEqual(
151
+ expect(await this.copyOfKeyValueService!.getKey("name")).toEqual(
179
152
  "defaultService1+modifierCommand",
180
153
  );
181
154
 
@@ -188,22 +161,13 @@ describe("BaseCLI tests", () => {
188
161
 
189
162
  async serviceMethod(context: Context): Promise<void> {
190
163
  expect(await this.copyOfKeyValueService!.hasKey("name")).toBeTrue();
191
- expect(await this.copyOfKeyValueService!.getKey("name")).toEqual(
192
- "subCommand",
193
- );
194
- await this.copyOfKeyValueService!.setKey(
195
- "name",
196
- "defaultService2+subCommand",
197
- );
164
+ expect(await this.copyOfKeyValueService!.getKey("name")).toEqual("subCommand");
165
+ await this.copyOfKeyValueService!.setKey("name", "defaultService2+subCommand");
198
166
 
199
- const keyValueService = context.getServiceById(
200
- KEY_VALUE_SERVICE_ID,
201
- ) as KeyValueService;
167
+ const keyValueService = context.getServiceById(KEY_VALUE_SERVICE_ID) as KeyValueService;
202
168
 
203
169
  expect(await keyValueService.hasKey("name")).toBeTrue();
204
- expect(
205
- await this.copyOfKeyValueService!.getKey("name"),
206
- ).toEqual(
170
+ expect(await this.copyOfKeyValueService!.getKey("name")).toEqual(
207
171
  "defaultService2+subCommand",
208
172
  );
209
173
 
@@ -226,9 +190,7 @@ describe("BaseCLI tests", () => {
226
190
  }
227
191
 
228
192
  async initService(context: Context): Promise<void> {
229
- const keyValueService = context.getServiceById(
230
- KEY_VALUE_SERVICE_ID,
231
- ) as KeyValueService;
193
+ const keyValueService = context.getServiceById(KEY_VALUE_SERVICE_ID) as KeyValueService;
232
194
 
233
195
  expect(await keyValueService.hasKey("name")).toBeFalse();
234
196
  await keyValueService.setKey("name", "defaultService2");
@@ -254,9 +216,7 @@ describe("BaseCLI tests", () => {
254
216
  }
255
217
 
256
218
  async initService(context: Context): Promise<void> {
257
- const keyValueService = context.getServiceById(
258
- KEY_VALUE_SERVICE_ID,
259
- ) as KeyValueService;
219
+ const keyValueService = context.getServiceById(KEY_VALUE_SERVICE_ID) as KeyValueService;
260
220
 
261
221
  expect(await keyValueService.hasKey("name")).toBeFalse();
262
222
  await keyValueService.setKey("name", "defaultService2");
@@ -267,14 +227,9 @@ describe("BaseCLI tests", () => {
267
227
  }
268
228
  }
269
229
 
270
- const modifierCommand = getGlobalModifierCommandWithArgument(
271
- "modifier",
272
- "m",
273
- 1,
274
- {
275
- type: ArgumentValueTypeName.STRING,
276
- },
277
- );
230
+ const modifierCommand = getGlobalModifierCommandWithArgument("modifier", "m", 1, {
231
+ type: ArgumentValueTypeName.STRING,
232
+ });
278
233
  const option = {
279
234
  name: "foo",
280
235
  type: ArgumentValueTypeName.STRING,
@@ -283,9 +238,7 @@ describe("BaseCLI tests", () => {
283
238
  const subCommand = getSubCommand("command", [option], []);
284
239
 
285
240
  modifierCommand.execute = async (context): Promise<void> => {
286
- const keyValueService = context.getServiceById(
287
- KEY_VALUE_SERVICE_ID,
288
- ) as KeyValueService;
241
+ const keyValueService = context.getServiceById(KEY_VALUE_SERVICE_ID) as KeyValueService;
289
242
 
290
243
  expect(await keyValueService.hasKey("name")).toBeFalse();
291
244
  await keyValueService.setKey("name", "modifierCommand");
@@ -297,9 +250,7 @@ describe("BaseCLI tests", () => {
297
250
  modifierHasRun = true;
298
251
  };
299
252
  subCommand.execute = async (context): Promise<void> => {
300
- const keyValueService = context.getServiceById(
301
- KEY_VALUE_SERVICE_ID,
302
- ) as KeyValueService;
253
+ const keyValueService = context.getServiceById(KEY_VALUE_SERVICE_ID) as KeyValueService;
303
254
 
304
255
  expect(await keyValueService.hasKey("name")).toBeFalse();
305
256
  await keyValueService.setKey("name", "subCommand");
@@ -316,13 +267,7 @@ describe("BaseCLI tests", () => {
316
267
  baseCLI.addCommand(modifierCommand);
317
268
  baseCLI.addCommand(subCommand);
318
269
 
319
- const runResult = await baseCLI.run([
320
- "unused",
321
- "--modifier=bar",
322
- "command",
323
- "--foo",
324
- "bar",
325
- ]);
270
+ const runResult = await baseCLI.run(["unused", "--modifier=bar", "command", "--foo", "bar"]);
326
271
 
327
272
  expect(runResult.runState).toEqual(RunState.SUCCESS);
328
273
  expect(serviceProvider1Initialised).toBeTrue();
@@ -333,8 +278,6 @@ describe("BaseCLI tests", () => {
333
278
  expect(service2MethodInvoked).toBeTrue();
334
279
 
335
280
  // cleanup
336
- await fs.rm(
337
- path.join(process.env.HOME!, `.${appName.replace(/\W/g, "")}.json`),
338
- );
281
+ await fs.rm(path.join(process.env.HOME!, `.${appName.replace(/\W/g, "")}.json`));
339
282
  });
340
283
  });
@@ -15,12 +15,7 @@ describe("CompletionIntegrationSubCommand", () => {
15
15
  const cmd = new CompletionIntegrationSubCommand();
16
16
  expect(cmd.positionals.length).toEqual(1);
17
17
  expect(cmd.positionals[0]!.name).toEqual("shell");
18
- expect(cmd.positionals[0]!.allowableValues).toEqual([
19
- "bash",
20
- "zsh",
21
- "fish",
22
- "powershell",
23
- ]);
18
+ expect(cmd.positionals[0]!.allowableValues).toEqual(["bash", "zsh", "fish", "powershell"]);
24
19
  });
25
20
 
26
21
  test("has optional config-path option", () => {