@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.
- package/README/core-service-providers.md +2 -2
- package/README/development.md +3 -6
- package/README/implementation-details.md +17 -17
- package/README/key-concepts.md +17 -17
- package/README.md +4 -4
- package/bun.lock +0 -2
- package/index.ts +22 -30
- package/package.json +19 -19
- package/src/api/argument/Argument.ts +1 -1
- package/src/api/argument/ArgumentValueTypes.ts +3 -10
- package/src/api/argument/ComplexOption.ts +5 -9
- package/src/api/command/GlobalCommand.ts +1 -4
- package/src/api/service/core/ArgumentPrompterService.ts +1 -3
- package/src/api/service/core/AsciiBannerGeneratorService.ts +1 -4
- package/src/api/service/core/CompletionService.ts +2 -6
- package/src/api/service/core/ImagePrinterService.ts +1 -2
- package/src/api/service/core/KeyValueService.ts +1 -2
- package/src/api/service/core/PrettyPrinterService.ts +1 -4
- package/src/api/service/core/PrinterService.ts +8 -9
- package/src/api/service/core/PrompterService.ts +4 -11
- package/src/api/service/core/ShutdownService.ts +1 -2
- package/src/api/service/core/SyntaxHighlighterService.ts +1 -5
- package/src/api/service/core/Table.ts +7 -25
- package/src/api/service/core/TreePrinterService.ts +1 -2
- package/src/cli/BaseCLI.ts +17 -47
- package/src/cli/DefaultRuntimeCLI.ts +1 -4
- package/src/command/CompletionCommand.ts +19 -45
- package/src/command/MultiCommandCliHelpCommand.ts +45 -92
- package/src/command/SingleCommandCliHelpCommand.ts +17 -28
- package/src/command/UsageCommand.ts +6 -12
- package/src/command/VersionCommand.ts +2 -6
- package/src/launcher.ts +4 -2
- package/src/runtime/DefaultContext.ts +2 -5
- package/src/runtime/argument/ArgumentTypeGuards.ts +1 -3
- package/src/runtime/command/CommandTypeGuards.ts +5 -14
- package/src/runtime/command/CommandValidator.ts +56 -118
- package/src/runtime/parser.ts +13 -17
- package/src/runtime/registry/CommandRegistry.ts +2 -7
- package/src/runtime/registry/DefaultCommandRegistry.ts +32 -84
- package/src/runtime/registry/DefaultServiceProviderRegistry.ts +3 -9
- package/src/runtime/runner.ts +103 -142
- package/src/runtime/scanner.ts +28 -46
- package/src/runtime/values/ValuePopulationResult.ts +1 -2
- package/src/runtime/values/argumentValueMerge.ts +16 -28
- package/src/runtime/values/argumentValueValidation.ts +21 -67
- package/src/runtime/values/globalCommandValuePopulation.ts +9 -18
- package/src/runtime/values/subCommandValuePopulation.ts +42 -65
- package/src/service/argumentPrompter/ArgumentPrompterServiceProvider.ts +3 -10
- package/src/service/argumentPrompter/DefaultArgumentPrompterService.ts +22 -59
- package/src/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.ts +5 -14
- package/src/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.ts +59 -77
- package/src/service/banner/BannerServiceProvider.ts +13 -35
- package/src/service/banner/command/NoBannerCommand.ts +2 -8
- package/src/service/chiselAsciiBannerGenerator/ChiselFontAsciiBannerGeneratorService.ts +5 -10
- package/src/service/completion/CompletionServiceProvider.ts +20 -48
- package/src/service/completion/DefaultCompletionService.ts +17 -56
- package/src/service/completion/shell/ShellHandler.ts +1 -3
- package/src/service/completion/shell/fish.ts +1 -1
- package/src/service/completion/shell/powershell.ts +2 -12
- package/src/service/completion/shell/zsh.ts +1 -1
- package/src/service/configuration/ConfigurationServiceProvider.ts +40 -133
- package/src/service/configuration/DefaultKeyValueService.ts +6 -20
- package/src/service/configuration/DefaultSecretService.ts +10 -14
- package/src/service/configuration/command/ConfigCommand.ts +1 -4
- package/src/service/configuration/command/DumpConfigCommand.ts +9 -21
- package/src/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.ts +5 -14
- package/src/service/dataDumpGenerator/DefaultDataDumpGeneratorService.ts +5 -12
- package/src/service/imagePrinter/DefaultImagePrinterService.ts +1 -5
- package/src/service/imagePrinter/ImagePrinterServiceProvider.ts +1 -4
- package/src/service/prettyPrinter/DefaultPrettyPrinterService.ts +4 -12
- package/src/service/prettyPrinter/PrettyPrinterServiceProvider.ts +3 -10
- package/src/service/printer/DefaultPrinterService.ts +20 -83
- package/src/service/printer/PrinterServiceProvider.ts +3 -11
- package/src/service/printer/command/DarkModeCommand.ts +3 -10
- package/src/service/printer/command/LogLevelCommand.ts +7 -26
- package/src/service/printer/command/NoColorCommand.ts +3 -10
- package/src/service/printer/command/NoHyperlinksCommand.ts +3 -10
- package/src/service/printer/terminal/Progress.ts +99 -90
- package/src/service/printer/terminal/Spinner.ts +7 -26
- package/src/service/prompter/DefaultPrompterService.ts +2 -6
- package/src/service/prompter/PrompterServiceProvider.ts +3 -11
- package/src/service/prompter/command/NoPromptCommand.ts +3 -10
- package/src/service/prompter/prompt/PromptContext.ts +5 -18
- package/src/service/prompter/prompt/promptMultiSelect.ts +6 -21
- package/src/service/prompter/prompt/promptOpenUrl.ts +7 -22
- package/src/service/prompter/prompt/promptSingleSelect.ts +6 -23
- package/src/service/prompter/prompt/promptText.ts +10 -27
- package/src/service/prompter/prompt/promptToggle.ts +8 -8
- package/src/service/shutdown/ShutdownServiceProvider.ts +3 -10
- package/src/service/syntaxHighlighter/DefaultSyntaxHighlighterService.ts +13 -26
- package/src/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.ts +8 -21
- package/src/service/tableGenerator/DefaultTableGeneratorService.ts +44 -68
- package/src/service/tableGenerator/TableGeneratorServiceProvider.ts +7 -16
- package/src/service/treePrinter/DefaultTreePrinterService.ts +2 -7
- package/src/service/treePrinter/TreePrinterServiceProvider.ts +4 -12
- package/src/terminal/ImageRenderer.ts +35 -54
- package/src/terminal/PngDecoder.ts +10 -19
- package/src/terminal/TtyStyler.ts +11 -9
- package/src/terminal/TtyTerminal.ts +2 -10
- package/src/terminal/supportsHyperlinks.ts +4 -10
- package/src/util/configHelper.ts +3 -10
- package/src/util/envVarHelper.ts +50 -88
- package/src/util/helpHelper.ts +123 -193
- package/src/util/logger.ts +12 -42
- package/src/util/runnerHelper.ts +20 -61
- package/tests/cli/BaseCLI.test.ts +23 -80
- package/tests/command/CompletionCommand.test.ts +1 -6
- package/tests/command/MultiCommandCliHelpCommand.test.ts +51 -205
- package/tests/command/SingleCommandCliHelpCommand.test.ts +21 -103
- package/tests/command/UsageCommand.test.ts +4 -10
- package/tests/fixtures/Command.ts +87 -68
- package/tests/fixtures/CommandRegistry.ts +1 -3
- package/tests/fixtures/Context.ts +3 -11
- package/tests/fixtures/ServiceProviderRegistry.ts +1 -1
- package/tests/fixtures/prettierPluginFoo.ts +1 -1
- package/tests/fixtures/util.ts +2 -8
- package/tests/runtime/argument/ArgumentTypeGuards.test.ts +1 -3
- package/tests/runtime/command/CommandValidator.test.ts +881 -604
- package/tests/runtime/parser.test.ts +222 -246
- package/tests/runtime/registry/DefaultCommandRegistry.test.ts +15 -37
- package/tests/runtime/registry/DefaultServiceProviderRegistry.test.ts +2 -8
- package/tests/runtime/runner.test.ts +231 -281
- package/tests/runtime/scanner.test.ts +277 -475
- package/tests/runtime/values/argumentValueMerge.test.ts +133 -81
- package/tests/runtime/values/argumentValueValidation.test.ts +444 -588
- package/tests/runtime/values/globalCommandValuePopulation.test.ts +71 -253
- package/tests/runtime/values/subCommandValuePopulation.test.ts +1342 -1570
- package/tests/service/argumentPrompter/ArgumentPrompterServiceProvider.test.ts +3 -12
- package/tests/service/argumentPrompter/DefaultArgumentPrompterService.test.ts +36 -45
- package/tests/service/asciiBannerGenerator/AsciiBannerGeneratorServiceProvider.test.ts +2 -8
- package/tests/service/asciiBannerGenerator/DefaultAsciiBannerGeneratorService.test.ts +40 -62
- package/tests/service/banner/BannerServiceProvider.test.ts +5 -18
- package/tests/service/banner/command/NoBannerCommand.test.ts +1 -4
- package/tests/service/completion/CompletionServiceProvider.test.ts +145 -214
- package/tests/service/completion/DefaultCompletionService.test.ts +17 -79
- package/tests/service/completion/shell/fish.test.ts +1 -3
- package/tests/service/configuration/ConfigurationServiceProvider.test.ts +26 -75
- package/tests/service/configuration/DefaultKeyValueService.test.ts +9 -21
- package/tests/service/configuration/DefaultSecretService.test.ts +7 -15
- package/tests/service/configuration/command/DumpConfigCommand.test.ts +4 -13
- package/tests/service/dataDumpGenerator/DataDumpGeneratorServiceProvider.test.ts +6 -12
- package/tests/service/dataDumpGenerator/DefaultDataDumpGeneratorService.test.ts +1 -10
- package/tests/service/imagePrinter/DefaultImagePrinterService.test.ts +5 -70
- package/tests/service/prettyPrinter/DefaultPrettyPrinterService.test.ts +4 -11
- package/tests/service/prettyPrinter/PrettyPrinterServiceProvider.test.ts +2 -6
- package/tests/service/printer/DefaultPrinterService.test.ts +57 -255
- package/tests/service/printer/PrinterServiceProvider.test.ts +2 -8
- package/tests/service/printer/command/DarkModeCommand.test.ts +4 -12
- package/tests/service/printer/command/LogLevelCommand.test.ts +4 -17
- package/tests/service/printer/command/NoColorCommand.test.ts +4 -12
- package/tests/service/printer/command/NoHyperlinksCommand.test.ts +7 -21
- package/tests/service/printer/terminal/Progress.test.ts +1 -3
- package/tests/service/printer/terminal/Spinner.test.ts +2 -8
- package/tests/service/prompter/DefaultPrompterService.test.ts +52 -69
- package/tests/service/prompter/PrompterServiceProvider.test.ts +2 -8
- package/tests/service/shutdown/ShutdownServiceProvider.test.ts +1 -3
- package/tests/service/syntaxHighlighter/DefaultSyntaxHighlighterService.test.ts +13 -99
- package/tests/service/syntaxHighlighter/SyntaxHighlighterServiceProvider.test.ts +2 -7
- package/tests/service/tableGenerator/DefaultTableGeneratorService.test.ts +12 -33
- package/tests/service/tableGenerator/TableGeneratorServiceProvider.test.ts +2 -2
- package/tests/service/treePrinter/DefaultTreePrinterService.test.ts +4 -6
- package/tests/service/treePrinter/TreePrinterServiceProvider.test.ts +4 -8
- package/tests/terminal/ImageRenderer.test.ts +2 -11
- package/tests/terminal/PngDecoder.test.ts +2 -6
- package/tests/util/configHelper.test.ts +55 -137
- package/tests/util/envVarHelper.test.ts +46 -110
|
@@ -5,10 +5,7 @@ import {
|
|
|
5
5
|
getGlobalModifierCommand,
|
|
6
6
|
getSubCommandWithOption,
|
|
7
7
|
} from "../fixtures/Command.ts";
|
|
8
|
-
import {
|
|
9
|
-
expectStringIncludes,
|
|
10
|
-
expectStringNotIncludes,
|
|
11
|
-
} from "../fixtures/util.ts";
|
|
8
|
+
import { expectStringIncludes, expectStringNotIncludes } from "../fixtures/util.ts";
|
|
12
9
|
import { getContext } from "../fixtures/Context.ts";
|
|
13
10
|
import {
|
|
14
11
|
MultiCommandCliHelpGlobalCommand,
|
|
@@ -24,15 +21,11 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
24
21
|
const streamString = new StreamString();
|
|
25
22
|
const context = getContext(streamString);
|
|
26
23
|
const commandRegistry = getCommandRegistry();
|
|
27
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
28
|
-
true,
|
|
29
|
-
commandRegistry,
|
|
30
|
-
);
|
|
24
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
31
25
|
|
|
32
26
|
commandRegistry.addCommand(help);
|
|
33
27
|
|
|
34
28
|
await help.execute(context);
|
|
35
|
-
streamString.getString().includes;
|
|
36
29
|
expectStringIncludes(streamString.getString(), "Usage");
|
|
37
30
|
expectStringIncludes(streamString.getString(), "foo <command>");
|
|
38
31
|
});
|
|
@@ -41,10 +34,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
41
34
|
const streamString = new StreamString();
|
|
42
35
|
const context = getContext(streamString);
|
|
43
36
|
const commandRegistry = getCommandRegistry();
|
|
44
|
-
const help = new MultiCommandCliHelpSubCommand(
|
|
45
|
-
true,
|
|
46
|
-
commandRegistry,
|
|
47
|
-
);
|
|
37
|
+
const help = new MultiCommandCliHelpSubCommand(true, commandRegistry);
|
|
48
38
|
|
|
49
39
|
commandRegistry.addCommand(help);
|
|
50
40
|
|
|
@@ -58,19 +48,13 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
58
48
|
const context = getContext(streamString);
|
|
59
49
|
const subCommand = getSubCommandWithOption("command_a");
|
|
60
50
|
const commandRegistry = getCommandRegistry([subCommand]);
|
|
61
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
62
|
-
true,
|
|
63
|
-
commandRegistry,
|
|
64
|
-
);
|
|
51
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
65
52
|
|
|
66
53
|
commandRegistry.addCommand(help);
|
|
67
54
|
|
|
68
55
|
await help.execute(context, "command_a");
|
|
69
56
|
expectStringIncludes(streamString.getString(), "Usage");
|
|
70
|
-
expectStringIncludes(
|
|
71
|
-
streamString.getString(),
|
|
72
|
-
subCommand.description!,
|
|
73
|
-
);
|
|
57
|
+
expectStringIncludes(streamString.getString(), subCommand.description!);
|
|
74
58
|
});
|
|
75
59
|
|
|
76
60
|
test("MultiCommandCliHelpSubCommand with command specified works", async () => {
|
|
@@ -78,37 +62,25 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
78
62
|
const context = getContext(streamString);
|
|
79
63
|
const subCommand = getSubCommandWithOption("command_a");
|
|
80
64
|
const commandRegistry = getCommandRegistry([subCommand]);
|
|
81
|
-
const help = new MultiCommandCliHelpSubCommand(
|
|
82
|
-
true,
|
|
83
|
-
commandRegistry,
|
|
84
|
-
);
|
|
65
|
+
const help = new MultiCommandCliHelpSubCommand(true, commandRegistry);
|
|
85
66
|
|
|
86
67
|
commandRegistry.addCommand(help);
|
|
87
68
|
|
|
88
69
|
await help.execute(context, { command: "command_a" });
|
|
89
70
|
expectStringIncludes(streamString.getString(), "Usage");
|
|
90
|
-
expectStringIncludes(
|
|
91
|
-
streamString.getString(),
|
|
92
|
-
subCommand.description!,
|
|
93
|
-
);
|
|
71
|
+
expectStringIncludes(streamString.getString(), subCommand.description!);
|
|
94
72
|
});
|
|
95
73
|
|
|
96
74
|
test("MultiCommandCliHelpGlobalCommand with unknown command specified error warning and generic help", async () => {
|
|
97
75
|
const streamString = new StreamString();
|
|
98
76
|
const context = getContext(streamString);
|
|
99
77
|
const commandRegistry = getCommandRegistry();
|
|
100
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
101
|
-
true,
|
|
102
|
-
commandRegistry,
|
|
103
|
-
);
|
|
78
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
104
79
|
|
|
105
80
|
commandRegistry.addCommand(help);
|
|
106
81
|
|
|
107
82
|
await help.execute(context, "hello");
|
|
108
|
-
expectStringIncludes(
|
|
109
|
-
streamString.getString(),
|
|
110
|
-
"Unknown command: hello",
|
|
111
|
-
);
|
|
83
|
+
expectStringIncludes(streamString.getString(), "Unknown command: hello");
|
|
112
84
|
expectStringIncludes(streamString.getString(), "Usage");
|
|
113
85
|
});
|
|
114
86
|
|
|
@@ -116,18 +88,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
116
88
|
const streamString = new StreamString();
|
|
117
89
|
const context = getContext(streamString);
|
|
118
90
|
const commandRegistry = getCommandRegistry();
|
|
119
|
-
const help = new MultiCommandCliHelpSubCommand(
|
|
120
|
-
true,
|
|
121
|
-
commandRegistry,
|
|
122
|
-
);
|
|
91
|
+
const help = new MultiCommandCliHelpSubCommand(true, commandRegistry);
|
|
123
92
|
|
|
124
93
|
commandRegistry.addCommand(help);
|
|
125
94
|
|
|
126
95
|
await help.execute(context, { command: "hello" });
|
|
127
|
-
expectStringIncludes(
|
|
128
|
-
streamString.getString(),
|
|
129
|
-
"Unknown command: hello",
|
|
130
|
-
);
|
|
96
|
+
expectStringIncludes(streamString.getString(), "Unknown command: hello");
|
|
131
97
|
expectStringIncludes(streamString.getString(), "Usage");
|
|
132
98
|
});
|
|
133
99
|
|
|
@@ -139,22 +105,13 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
139
105
|
getSubCommandWithOption("command_a"),
|
|
140
106
|
getSubCommandWithOption("other2"),
|
|
141
107
|
]);
|
|
142
|
-
const help = new MultiCommandCliHelpSubCommand(
|
|
143
|
-
true,
|
|
144
|
-
commandRegistry,
|
|
145
|
-
);
|
|
108
|
+
const help = new MultiCommandCliHelpSubCommand(true, commandRegistry);
|
|
146
109
|
|
|
147
110
|
commandRegistry.addCommand(help);
|
|
148
111
|
|
|
149
112
|
await help.execute(context, { command: "command_b" });
|
|
150
|
-
expectStringIncludes(
|
|
151
|
-
|
|
152
|
-
"Possible matches: command_a",
|
|
153
|
-
);
|
|
154
|
-
expectStringIncludes(
|
|
155
|
-
streamString.getString(),
|
|
156
|
-
"Unknown command: command_b",
|
|
157
|
-
);
|
|
113
|
+
expectStringIncludes(streamString.getString(), "Possible matches: command_a");
|
|
114
|
+
expectStringIncludes(streamString.getString(), "Unknown command: command_b");
|
|
158
115
|
expectStringIncludes(streamString.getString(), "Usage");
|
|
159
116
|
});
|
|
160
117
|
|
|
@@ -165,10 +122,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
165
122
|
getGlobalModifierCommand("zzz", "z", true),
|
|
166
123
|
getGlobalModifierCommand("aaa", "a", true),
|
|
167
124
|
]);
|
|
168
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
169
|
-
true,
|
|
170
|
-
commandRegistry,
|
|
171
|
-
);
|
|
125
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
172
126
|
|
|
173
127
|
commandRegistry.addCommand(help);
|
|
174
128
|
|
|
@@ -194,10 +148,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
194
148
|
execute: async (): Promise<void> => {},
|
|
195
149
|
} as GroupCommand,
|
|
196
150
|
]);
|
|
197
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
198
|
-
true,
|
|
199
|
-
commandRegistry,
|
|
200
|
-
);
|
|
151
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
201
152
|
|
|
202
153
|
commandRegistry.addCommand(help);
|
|
203
154
|
|
|
@@ -229,10 +180,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
229
180
|
execute: async (): Promise<void> => {},
|
|
230
181
|
} as GroupCommand,
|
|
231
182
|
]);
|
|
232
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
233
|
-
true,
|
|
234
|
-
commandRegistry,
|
|
235
|
-
);
|
|
183
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
236
184
|
|
|
237
185
|
commandRegistry.addCommand(help);
|
|
238
186
|
|
|
@@ -258,10 +206,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
258
206
|
execute: async (): Promise<void> => {},
|
|
259
207
|
} as GroupCommand,
|
|
260
208
|
]);
|
|
261
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
262
|
-
true,
|
|
263
|
-
commandRegistry,
|
|
264
|
-
);
|
|
209
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
265
210
|
|
|
266
211
|
commandRegistry.addCommand(help);
|
|
267
212
|
|
|
@@ -281,10 +226,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
281
226
|
execute: async (): Promise<void> => {},
|
|
282
227
|
} as SubCommand,
|
|
283
228
|
]);
|
|
284
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
285
|
-
true,
|
|
286
|
-
commandRegistry,
|
|
287
|
-
);
|
|
229
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
288
230
|
|
|
289
231
|
commandRegistry.addCommand(help);
|
|
290
232
|
|
|
@@ -299,10 +241,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
299
241
|
getGlobalModifierCommand("zzz"),
|
|
300
242
|
getGlobalModifierCommand("aaa"),
|
|
301
243
|
]);
|
|
302
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
303
|
-
true,
|
|
304
|
-
commandRegistry,
|
|
305
|
-
);
|
|
244
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
306
245
|
|
|
307
246
|
commandRegistry.addCommand(help);
|
|
308
247
|
|
|
@@ -321,10 +260,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
321
260
|
getGlobalModifierCommand("aaa", "a", true),
|
|
322
261
|
getSubCommandWithOption("command_a"),
|
|
323
262
|
]);
|
|
324
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
325
|
-
true,
|
|
326
|
-
commandRegistry,
|
|
327
|
-
);
|
|
263
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
328
264
|
|
|
329
265
|
commandRegistry.addCommand(help);
|
|
330
266
|
|
|
@@ -339,19 +275,13 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
339
275
|
const streamString = new StreamString();
|
|
340
276
|
const context = getContext(streamString);
|
|
341
277
|
const commandRegistry = getCommandRegistry();
|
|
342
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
343
|
-
true,
|
|
344
|
-
commandRegistry,
|
|
345
|
-
);
|
|
278
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
346
279
|
|
|
347
280
|
commandRegistry.addCommand(help);
|
|
348
281
|
|
|
349
282
|
await help.execute(context);
|
|
350
283
|
expectStringIncludes(streamString.getString(), "foo");
|
|
351
|
-
expectStringNotIncludes(
|
|
352
|
-
streamString.getString(),
|
|
353
|
-
"global_option",
|
|
354
|
-
);
|
|
284
|
+
expectStringNotIncludes(streamString.getString(), "global_option");
|
|
355
285
|
});
|
|
356
286
|
|
|
357
287
|
test("Ensure multi-command CLI usage syntax is rendered correctly: render global_option arg if global modifiers defined", async () => {
|
|
@@ -362,18 +292,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
362
292
|
getGlobalModifierCommand("modifier2"),
|
|
363
293
|
getSubCommandWithOption("command_a"),
|
|
364
294
|
]);
|
|
365
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
366
|
-
true,
|
|
367
|
-
commandRegistry,
|
|
368
|
-
);
|
|
295
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
369
296
|
|
|
370
297
|
commandRegistry.addCommand(help);
|
|
371
298
|
|
|
372
299
|
await help.execute(context);
|
|
373
|
-
expectStringIncludes(
|
|
374
|
-
streamString.getString(),
|
|
375
|
-
"[<global_option> [<value>]]...",
|
|
376
|
-
);
|
|
300
|
+
expectStringIncludes(streamString.getString(), "[<global_option> [<value>]]...");
|
|
377
301
|
});
|
|
378
302
|
|
|
379
303
|
test("Ensure multi-command CLI usage syntax is rendered correctly: do not render global_option multiplicity if only one defined", async () => {
|
|
@@ -383,18 +307,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
383
307
|
getGlobalModifierCommand("modifier1"),
|
|
384
308
|
getSubCommandWithOption("command_a"),
|
|
385
309
|
]);
|
|
386
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
387
|
-
true,
|
|
388
|
-
commandRegistry,
|
|
389
|
-
);
|
|
310
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
390
311
|
|
|
391
312
|
commandRegistry.addCommand(help);
|
|
392
313
|
|
|
393
314
|
await help.execute(context);
|
|
394
|
-
expectStringIncludes(
|
|
395
|
-
streamString.getString(),
|
|
396
|
-
"[<global_option>] <global_command>",
|
|
397
|
-
);
|
|
315
|
+
expectStringIncludes(streamString.getString(), "[<global_option>] <global_command>");
|
|
398
316
|
});
|
|
399
317
|
|
|
400
318
|
test("Ensure multi-command CLI usage syntax is rendered correctly: do not render global_option arg if none defined", async () => {
|
|
@@ -405,18 +323,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
405
323
|
getGlobalModifierCommand("modifier2"),
|
|
406
324
|
getSubCommandWithOption("command_a"),
|
|
407
325
|
]);
|
|
408
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
409
|
-
true,
|
|
410
|
-
commandRegistry,
|
|
411
|
-
);
|
|
326
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
412
327
|
|
|
413
328
|
commandRegistry.addCommand(help);
|
|
414
329
|
|
|
415
330
|
await help.execute(context);
|
|
416
|
-
expectStringIncludes(
|
|
417
|
-
streamString.getString(),
|
|
418
|
-
"[<global_option>]... <global_command>",
|
|
419
|
-
);
|
|
331
|
+
expectStringIncludes(streamString.getString(), "[<global_option>]... <global_command>");
|
|
420
332
|
});
|
|
421
333
|
|
|
422
334
|
test("Ensure multi-command CLI usage syntax is rendered correctly: do not render global_option arg as optional if none are optional and have no default or not boolean", async () => {
|
|
@@ -427,18 +339,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
427
339
|
getGlobalModifierCommand("modifier2", "2", true, true),
|
|
428
340
|
getSubCommandWithOption("command_a"),
|
|
429
341
|
]);
|
|
430
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
431
|
-
true,
|
|
432
|
-
commandRegistry,
|
|
433
|
-
);
|
|
342
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
434
343
|
|
|
435
344
|
commandRegistry.addCommand(help);
|
|
436
345
|
|
|
437
346
|
await help.execute(context);
|
|
438
|
-
expectStringIncludes(
|
|
439
|
-
streamString.getString(),
|
|
440
|
-
"[<global_option> <value>]",
|
|
441
|
-
);
|
|
347
|
+
expectStringIncludes(streamString.getString(), "[<global_option> <value>]");
|
|
442
348
|
});
|
|
443
349
|
|
|
444
350
|
test("Ensure multi-command CLI usage syntax is rendered correctly: render global_option arg as optional if at least one modifier has no arg", async () => {
|
|
@@ -449,18 +355,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
449
355
|
getGlobalModifierCommand("modifier2"),
|
|
450
356
|
getSubCommandWithOption("command_a"),
|
|
451
357
|
]);
|
|
452
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
453
|
-
true,
|
|
454
|
-
commandRegistry,
|
|
455
|
-
);
|
|
358
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
456
359
|
|
|
457
360
|
commandRegistry.addCommand(help);
|
|
458
361
|
|
|
459
362
|
await help.execute(context);
|
|
460
|
-
expectStringIncludes(
|
|
461
|
-
streamString.getString(),
|
|
462
|
-
"[<global_option> [<value>]]",
|
|
463
|
-
);
|
|
363
|
+
expectStringIncludes(streamString.getString(), "[<global_option> [<value>]]");
|
|
464
364
|
});
|
|
465
365
|
|
|
466
366
|
test("Ensure multi-command CLI usage syntax is rendered correctly: do not render command if none defined (e.g. default command is configured)", async () => {
|
|
@@ -470,10 +370,7 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
470
370
|
getGlobalModifierCommand("modifier1"),
|
|
471
371
|
getGlobalModifierCommand("modifier2"),
|
|
472
372
|
]);
|
|
473
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
474
|
-
true,
|
|
475
|
-
commandRegistry,
|
|
476
|
-
);
|
|
373
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
477
374
|
|
|
478
375
|
commandRegistry.addCommand(help);
|
|
479
376
|
|
|
@@ -484,33 +381,20 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
484
381
|
test("Ensure multi-command CLI usage syntax is rendered correctly: render command and global command", async () => {
|
|
485
382
|
const streamString = new StreamString();
|
|
486
383
|
const context = getContext(streamString);
|
|
487
|
-
const commandRegistry = getCommandRegistry([
|
|
488
|
-
|
|
489
|
-
]);
|
|
490
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
491
|
-
true,
|
|
492
|
-
commandRegistry,
|
|
493
|
-
);
|
|
384
|
+
const commandRegistry = getCommandRegistry([getSubCommandWithOption("command_a")]);
|
|
385
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
494
386
|
|
|
495
387
|
commandRegistry.addCommand(help);
|
|
496
388
|
|
|
497
389
|
await help.execute(context);
|
|
498
|
-
expectStringIncludes(
|
|
499
|
-
streamString.getString(),
|
|
500
|
-
"<global_command>|<command>",
|
|
501
|
-
);
|
|
390
|
+
expectStringIncludes(streamString.getString(), "<global_command>|<command>");
|
|
502
391
|
});
|
|
503
392
|
|
|
504
393
|
test("Ensure multi-command CLI usage syntax is rendered correctly: do not render arg if none defined", async () => {
|
|
505
394
|
const streamString = new StreamString();
|
|
506
395
|
const context = getContext(streamString);
|
|
507
|
-
const commandRegistry = getCommandRegistry([
|
|
508
|
-
|
|
509
|
-
]);
|
|
510
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
511
|
-
true,
|
|
512
|
-
commandRegistry,
|
|
513
|
-
);
|
|
396
|
+
const commandRegistry = getCommandRegistry([getSubCommandWithOption("command_a")]);
|
|
397
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
514
398
|
|
|
515
399
|
commandRegistry.addCommand(help);
|
|
516
400
|
|
|
@@ -521,13 +405,8 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
521
405
|
test("Ensure multi-command CLI usage syntax is rendered correctly: render arg if at least one defined", async () => {
|
|
522
406
|
const streamString = new StreamString();
|
|
523
407
|
const context = getContext(streamString);
|
|
524
|
-
const commandRegistry = getCommandRegistry([
|
|
525
|
-
|
|
526
|
-
]);
|
|
527
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
528
|
-
true,
|
|
529
|
-
commandRegistry,
|
|
530
|
-
);
|
|
408
|
+
const commandRegistry = getCommandRegistry([getSubCommandWithOption("command_a", true, true)]);
|
|
409
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
531
410
|
|
|
532
411
|
commandRegistry.addCommand(help);
|
|
533
412
|
|
|
@@ -542,18 +421,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
542
421
|
getSubCommandWithOption("command_a", true, true),
|
|
543
422
|
getSubCommandWithOption("command_b", true),
|
|
544
423
|
]);
|
|
545
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
546
|
-
true,
|
|
547
|
-
commandRegistry,
|
|
548
|
-
);
|
|
424
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
549
425
|
|
|
550
426
|
commandRegistry.addCommand(help);
|
|
551
427
|
|
|
552
428
|
await help.execute(context);
|
|
553
|
-
expectStringIncludes(
|
|
554
|
-
streamString.getString(),
|
|
555
|
-
"<command> [<arg> <value>]",
|
|
556
|
-
);
|
|
429
|
+
expectStringIncludes(streamString.getString(), "<command> [<arg> <value>]");
|
|
557
430
|
});
|
|
558
431
|
|
|
559
432
|
test("Ensure multi-command CLI usage syntax is rendered correctly: render arg as multiple if at least one multiple", async () => {
|
|
@@ -563,18 +436,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
563
436
|
getSubCommandWithOption("command_a", true, true, true),
|
|
564
437
|
getSubCommandWithOption("command_b", true),
|
|
565
438
|
]);
|
|
566
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
567
|
-
true,
|
|
568
|
-
commandRegistry,
|
|
569
|
-
);
|
|
439
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
570
440
|
|
|
571
441
|
commandRegistry.addCommand(help);
|
|
572
442
|
|
|
573
443
|
await help.execute(context);
|
|
574
|
-
expectStringIncludes(
|
|
575
|
-
streamString.getString(),
|
|
576
|
-
"<command> [<arg> <value>]...",
|
|
577
|
-
);
|
|
444
|
+
expectStringIncludes(streamString.getString(), "<command> [<arg> <value>]...");
|
|
578
445
|
});
|
|
579
446
|
|
|
580
447
|
test("Ensure multi-command CLI usage syntax is rendered correctly: do not render arg value in [] if none are optional and have no default or not boolean", async () => {
|
|
@@ -584,16 +451,10 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
584
451
|
getSubCommandWithOption("command_a", true, true, true),
|
|
585
452
|
getSubCommandWithOption("command_b", true, true, true),
|
|
586
453
|
]);
|
|
587
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
588
|
-
true,
|
|
589
|
-
commandRegistry,
|
|
590
|
-
);
|
|
454
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
591
455
|
|
|
592
456
|
await help.execute(context);
|
|
593
|
-
expectStringIncludes(
|
|
594
|
-
streamString.getString(),
|
|
595
|
-
"<command> <<arg> <value>>...",
|
|
596
|
-
);
|
|
457
|
+
expectStringIncludes(streamString.getString(), "<command> <<arg> <value>>...");
|
|
597
458
|
});
|
|
598
459
|
|
|
599
460
|
test("Ensure multi-command CLI usage syntax is rendered correctly: multiple global and sub commands", async () => {
|
|
@@ -605,18 +466,12 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
605
466
|
getSubCommandWithOption("command_a", true, true),
|
|
606
467
|
getSubCommandWithOption("command_b", true),
|
|
607
468
|
]);
|
|
608
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
609
|
-
true,
|
|
610
|
-
commandRegistry,
|
|
611
|
-
);
|
|
469
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
612
470
|
|
|
613
471
|
commandRegistry.addCommand(help);
|
|
614
472
|
|
|
615
473
|
await help.execute(context);
|
|
616
|
-
expectStringIncludes(
|
|
617
|
-
streamString.getString(),
|
|
618
|
-
"<global_command>|<command> [<arg> <value>]",
|
|
619
|
-
);
|
|
474
|
+
expectStringIncludes(streamString.getString(), "<global_command>|<command> [<arg> <value>]");
|
|
620
475
|
});
|
|
621
476
|
|
|
622
477
|
test("Ensure multi-command CLI usage syntax is rendered correctly: multiple global and sub commands with multiple args and optional values", async () => {
|
|
@@ -625,19 +480,10 @@ describe("MultiCommandCliHelpCommand tests", () => {
|
|
|
625
480
|
const commandRegistry = getCommandRegistry([
|
|
626
481
|
getGlobalCommand("global1", true, true),
|
|
627
482
|
getGlobalCommand("global2", true),
|
|
628
|
-
getSubCommandWithOption(
|
|
629
|
-
"command_a",
|
|
630
|
-
true,
|
|
631
|
-
true,
|
|
632
|
-
true,
|
|
633
|
-
ArgumentValueTypeName.BOOLEAN,
|
|
634
|
-
),
|
|
483
|
+
getSubCommandWithOption("command_a", true, true, true, ArgumentValueTypeName.BOOLEAN),
|
|
635
484
|
getSubCommandWithOption("command_b", true),
|
|
636
485
|
]);
|
|
637
|
-
const help = new MultiCommandCliHelpGlobalCommand(
|
|
638
|
-
true,
|
|
639
|
-
commandRegistry,
|
|
640
|
-
);
|
|
486
|
+
const help = new MultiCommandCliHelpGlobalCommand(true, commandRegistry);
|
|
641
487
|
|
|
642
488
|
commandRegistry.addCommand(help);
|
|
643
489
|
|