@flowscripter/dynamic-cli-framework 9.0.2 → 9.0.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpHelper.d.ts","sourceRoot":"","sources":["../../../src/util/helpHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAG7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAIvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAM5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAG9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"helpHelper.d.ts","sourceRoot":"","sources":["../../../src/util/helpHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAG7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAIvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAM5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAG9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC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,CAAC,UAAU,CAAC,GACrC,MAAM,CA8IR;AAED,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,EAC1C,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,GACrC,MAAM,EAAE,CAkBV"}
|
|
@@ -4,6 +4,27 @@ import { getGlobalCommandArgumentConfigurationKey, getSubCommandArgumentConfigur
|
|
|
4
4
|
const SYNTAX_INDENT_WIDTH = 2;
|
|
5
5
|
const MINIMUM_SYNTAX_COLUMN_WIDTH = 15;
|
|
6
6
|
const HELP_SYNTAX_INDENT = " ".repeat(SYNTAX_INDENT_WIDTH);
|
|
7
|
+
const USER_INPUT_START = "\uE000";
|
|
8
|
+
const USER_INPUT_END = "\uE001";
|
|
9
|
+
const USER_INPUT_PATTERN = new RegExp(`${USER_INPUT_START}(.*?)${USER_INPUT_END}`, "gs");
|
|
10
|
+
function userInput(value) {
|
|
11
|
+
return `${USER_INPUT_START}${value}${USER_INPUT_END}`;
|
|
12
|
+
}
|
|
13
|
+
function renderDescription(printerService, description) {
|
|
14
|
+
let rendered = "";
|
|
15
|
+
let last = 0;
|
|
16
|
+
for (const match of description.matchAll(USER_INPUT_PATTERN)) {
|
|
17
|
+
if (match.index > last) {
|
|
18
|
+
rendered += printerService.secondary(description.slice(last, match.index));
|
|
19
|
+
}
|
|
20
|
+
rendered += printerService.primary(match[1]);
|
|
21
|
+
last = match.index + match[0].length;
|
|
22
|
+
}
|
|
23
|
+
if (last < description.length) {
|
|
24
|
+
rendered += printerService.secondary(description.slice(last));
|
|
25
|
+
}
|
|
26
|
+
return rendered;
|
|
27
|
+
}
|
|
7
28
|
function flattenHelpEntry(printerService, helpEntry, indentText, isRoot, isLastSibling, rows) {
|
|
8
29
|
let syntax = "";
|
|
9
30
|
if (helpEntry.syntax) {
|
|
@@ -22,7 +43,7 @@ function flattenHelpEntry(printerService, helpEntry, indentText, isRoot, isLastS
|
|
|
22
43
|
}
|
|
23
44
|
}
|
|
24
45
|
const description = helpEntry.description
|
|
25
|
-
? printerService
|
|
46
|
+
? renderDescription(printerService, helpEntry.description)
|
|
26
47
|
: undefined;
|
|
27
48
|
rows.push({ syntax, description });
|
|
28
49
|
if (helpEntry.helpSubEntries !== undefined) {
|
|
@@ -101,7 +122,7 @@ export function getGlobalArgumentHelpEntry(cliConfig, includeEnvVars, globalComm
|
|
|
101
122
|
const syntax = getGlobalCommandArgumentForm(argument);
|
|
102
123
|
const notesItems = [];
|
|
103
124
|
if (argument.allowableValues !== undefined && argument.allowableValues.length > 0) {
|
|
104
|
-
notesItems.push(`valid values: ${argument.allowableValues.join("|")}`);
|
|
125
|
+
notesItems.push(`valid values: ${userInput(argument.allowableValues.join("|"))}`);
|
|
105
126
|
}
|
|
106
127
|
else {
|
|
107
128
|
switch (argument.type) {
|
|
@@ -127,7 +148,7 @@ export function getGlobalArgumentHelpEntry(cliConfig, includeEnvVars, globalComm
|
|
|
127
148
|
}
|
|
128
149
|
}
|
|
129
150
|
if (argument.defaultValue !== undefined) {
|
|
130
|
-
notesItems.push(`default: ${argument.defaultValue}`);
|
|
151
|
+
notesItems.push(`default: ${userInput(String(argument.defaultValue))}`);
|
|
131
152
|
}
|
|
132
153
|
if (includeEnvVars) {
|
|
133
154
|
const configurationKey = getGlobalCommandArgumentConfigurationKey(cliConfig, globalCommand, argument);
|
|
@@ -214,7 +235,7 @@ function getOptionHelpEntry(cliConfig, includeEnvVars, command, option, subEntry
|
|
|
214
235
|
}
|
|
215
236
|
else {
|
|
216
237
|
if (option.allowableValues !== undefined && option.allowableValues.length > 0) {
|
|
217
|
-
notesItems.push(`valid values: ${option.allowableValues.join("|")}`);
|
|
238
|
+
notesItems.push(`valid values: ${userInput(option.allowableValues.join("|"))}`);
|
|
218
239
|
}
|
|
219
240
|
else {
|
|
220
241
|
switch (option.type) {
|
|
@@ -244,9 +265,9 @@ function getOptionHelpEntry(cliConfig, includeEnvVars, command, option, subEntry
|
|
|
244
265
|
notesItems.push(range);
|
|
245
266
|
}
|
|
246
267
|
if (option.defaultValue !== undefined) {
|
|
247
|
-
notesItems.push(`default: ${Array.isArray(option.defaultValue)
|
|
268
|
+
notesItems.push(`default: ${userInput(Array.isArray(option.defaultValue)
|
|
248
269
|
? `${option.defaultValue.join(", ")}`
|
|
249
|
-
: `${option.defaultValue}`}`);
|
|
270
|
+
: `${option.defaultValue}`)}`);
|
|
250
271
|
}
|
|
251
272
|
if (option.isOptional) {
|
|
252
273
|
notesItems.push("optional");
|
|
@@ -282,7 +303,7 @@ function getOptionHelpEntry(cliConfig, includeEnvVars, command, option, subEntry
|
|
|
282
303
|
function getPositionalHelpEntry(cliConfig, includeEnvVars, command, positional) {
|
|
283
304
|
const notesItems = [];
|
|
284
305
|
if (positional.allowableValues !== undefined && positional.allowableValues.length > 0) {
|
|
285
|
-
notesItems.push(`valid values: ${positional.allowableValues.join("|")}`);
|
|
306
|
+
notesItems.push(`valid values: ${userInput(positional.allowableValues.join("|"))}`);
|
|
286
307
|
}
|
|
287
308
|
else {
|
|
288
309
|
switch (positional.type) {
|
package/package.json
CHANGED
package/src/util/helpHelper.ts
CHANGED
|
@@ -23,6 +23,29 @@ import type { TableGeneratorService } from "@flowscripter/dynamic-cli-framework-
|
|
|
23
23
|
const SYNTAX_INDENT_WIDTH = 2;
|
|
24
24
|
const MINIMUM_SYNTAX_COLUMN_WIDTH = 15;
|
|
25
25
|
const HELP_SYNTAX_INDENT = " ".repeat(SYNTAX_INDENT_WIDTH);
|
|
26
|
+
const USER_INPUT_START = "\uE000";
|
|
27
|
+
const USER_INPUT_END = "\uE001";
|
|
28
|
+
const USER_INPUT_PATTERN = new RegExp(`${USER_INPUT_START}(.*?)${USER_INPUT_END}`, "gs");
|
|
29
|
+
|
|
30
|
+
function userInput(value: string): string {
|
|
31
|
+
return `${USER_INPUT_START}${value}${USER_INPUT_END}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function renderDescription(printerService: PrinterService, description: string): string {
|
|
35
|
+
let rendered = "";
|
|
36
|
+
let last = 0;
|
|
37
|
+
for (const match of description.matchAll(USER_INPUT_PATTERN)) {
|
|
38
|
+
if (match.index > last) {
|
|
39
|
+
rendered += printerService.secondary(description.slice(last, match.index));
|
|
40
|
+
}
|
|
41
|
+
rendered += printerService.primary(match[1]!);
|
|
42
|
+
last = match.index + match[0].length;
|
|
43
|
+
}
|
|
44
|
+
if (last < description.length) {
|
|
45
|
+
rendered += printerService.secondary(description.slice(last));
|
|
46
|
+
}
|
|
47
|
+
return rendered;
|
|
48
|
+
}
|
|
26
49
|
|
|
27
50
|
export interface HelpEntry {
|
|
28
51
|
readonly syntax: string;
|
|
@@ -66,7 +89,7 @@ function flattenHelpEntry(
|
|
|
66
89
|
}
|
|
67
90
|
|
|
68
91
|
const description = helpEntry.description
|
|
69
|
-
? printerService
|
|
92
|
+
? renderDescription(printerService, helpEntry.description)
|
|
70
93
|
: undefined;
|
|
71
94
|
|
|
72
95
|
rows.push({ syntax, description });
|
|
@@ -178,7 +201,7 @@ export function getGlobalArgumentHelpEntry(
|
|
|
178
201
|
|
|
179
202
|
const notesItems: Array<string> = [];
|
|
180
203
|
if (argument.allowableValues !== undefined && argument.allowableValues.length > 0) {
|
|
181
|
-
notesItems.push(`valid values: ${argument.allowableValues.join("|")}`);
|
|
204
|
+
notesItems.push(`valid values: ${userInput(argument.allowableValues.join("|"))}`);
|
|
182
205
|
} else {
|
|
183
206
|
switch (argument.type) {
|
|
184
207
|
case ValueTypeName.STRING:
|
|
@@ -205,7 +228,7 @@ export function getGlobalArgumentHelpEntry(
|
|
|
205
228
|
}
|
|
206
229
|
|
|
207
230
|
if (argument.defaultValue !== undefined) {
|
|
208
|
-
notesItems.push(`default: ${argument.defaultValue}`);
|
|
231
|
+
notesItems.push(`default: ${userInput(String(argument.defaultValue))}`);
|
|
209
232
|
}
|
|
210
233
|
|
|
211
234
|
if (includeEnvVars) {
|
|
@@ -309,7 +332,7 @@ function getOptionHelpEntry(
|
|
|
309
332
|
});
|
|
310
333
|
} else {
|
|
311
334
|
if (option.allowableValues !== undefined && option.allowableValues.length > 0) {
|
|
312
|
-
notesItems.push(`valid values: ${option.allowableValues.join("|")}`);
|
|
335
|
+
notesItems.push(`valid values: ${userInput(option.allowableValues.join("|"))}`);
|
|
313
336
|
} else {
|
|
314
337
|
switch (option.type) {
|
|
315
338
|
case ValueTypeName.STRING:
|
|
@@ -341,11 +364,11 @@ function getOptionHelpEntry(
|
|
|
341
364
|
|
|
342
365
|
if (option.defaultValue !== undefined) {
|
|
343
366
|
notesItems.push(
|
|
344
|
-
`default: ${
|
|
367
|
+
`default: ${userInput(
|
|
345
368
|
Array.isArray(option.defaultValue)
|
|
346
369
|
? `${option.defaultValue.join(", ")}`
|
|
347
|
-
: `${option.defaultValue}
|
|
348
|
-
}`,
|
|
370
|
+
: `${option.defaultValue}`,
|
|
371
|
+
)}`,
|
|
349
372
|
);
|
|
350
373
|
}
|
|
351
374
|
|
|
@@ -394,7 +417,7 @@ function getPositionalHelpEntry(
|
|
|
394
417
|
): HelpEntry {
|
|
395
418
|
const notesItems: Array<string> = [];
|
|
396
419
|
if (positional.allowableValues !== undefined && positional.allowableValues.length > 0) {
|
|
397
|
-
notesItems.push(`valid values: ${positional.allowableValues.join("|")}`);
|
|
420
|
+
notesItems.push(`valid values: ${userInput(positional.allowableValues.join("|"))}`);
|
|
398
421
|
} else {
|
|
399
422
|
switch (positional.type) {
|
|
400
423
|
case ValueTypeName.STRING:
|