@flowscripter/dynamic-cli-framework-api 1.0.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.
- package/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/src/BaseCLIFeatureOptions.d.ts +12 -0
- package/dist/src/BaseCLIFeatureOptions.d.ts.map +1 -0
- package/dist/src/BaseCLIFeatureOptions.js +0 -0
- package/dist/src/CLI.d.ts +17 -0
- package/dist/src/CLI.d.ts.map +1 -0
- package/dist/src/CLI.js +0 -0
- package/dist/src/CLIConfig.d.ts +22 -0
- package/dist/src/CLIConfig.d.ts.map +1 -0
- package/dist/src/CLIConfig.js +0 -0
- package/dist/src/Context.d.ts +23 -0
- package/dist/src/Context.d.ts.map +1 -0
- package/dist/src/Context.js +0 -0
- package/dist/src/ParseResult.d.ts +33 -0
- package/dist/src/ParseResult.d.ts.map +1 -0
- package/dist/src/ParseResult.js +0 -0
- package/dist/src/RunResult.d.ts +128 -0
- package/dist/src/RunResult.d.ts.map +1 -0
- package/dist/src/RunResult.js +73 -0
- package/dist/src/argument/Argument.d.ts +62 -0
- package/dist/src/argument/Argument.d.ts.map +1 -0
- package/dist/src/argument/Argument.js +0 -0
- package/dist/src/argument/ArgumentValueTypes.d.ts +68 -0
- package/dist/src/argument/ArgumentValueTypes.d.ts.map +1 -0
- package/dist/src/argument/ArgumentValueTypes.js +18 -0
- package/dist/src/argument/ComplexOption.d.ts +21 -0
- package/dist/src/argument/ComplexOption.d.ts.map +1 -0
- package/dist/src/argument/ComplexOption.js +1 -0
- package/dist/src/argument/GlobalCommandArgument.d.ts +16 -0
- package/dist/src/argument/GlobalCommandArgument.d.ts.map +1 -0
- package/dist/src/argument/GlobalCommandArgument.js +0 -0
- package/dist/src/argument/Option.d.ts +29 -0
- package/dist/src/argument/Option.d.ts.map +1 -0
- package/dist/src/argument/Option.js +0 -0
- package/dist/src/argument/Positional.d.ts +26 -0
- package/dist/src/argument/Positional.d.ts.map +1 -0
- package/dist/src/argument/Positional.js +0 -0
- package/dist/src/argument/SubCommandArgument.d.ts +18 -0
- package/dist/src/argument/SubCommandArgument.d.ts.map +1 -0
- package/dist/src/argument/SubCommandArgument.js +1 -0
- package/dist/src/command/Command.d.ts +26 -0
- package/dist/src/command/Command.d.ts.map +1 -0
- package/dist/src/command/Command.js +0 -0
- package/dist/src/command/GlobalCommand.d.ts +28 -0
- package/dist/src/command/GlobalCommand.d.ts.map +1 -0
- package/dist/src/command/GlobalCommand.js +0 -0
- package/dist/src/command/GlobalModifierCommand.d.ts +12 -0
- package/dist/src/command/GlobalModifierCommand.d.ts.map +1 -0
- package/dist/src/command/GlobalModifierCommand.js +0 -0
- package/dist/src/command/GroupCommand.d.ts +19 -0
- package/dist/src/command/GroupCommand.d.ts.map +1 -0
- package/dist/src/command/GroupCommand.js +0 -0
- package/dist/src/command/SubCommand.d.ts +37 -0
- package/dist/src/command/SubCommand.d.ts.map +1 -0
- package/dist/src/command/SubCommand.js +0 -0
- package/dist/src/command/UsageExample.d.ts +20 -0
- package/dist/src/command/UsageExample.d.ts.map +1 -0
- package/dist/src/command/UsageExample.js +0 -0
- package/dist/src/plugin/CLIPlugin.d.ts +32 -0
- package/dist/src/plugin/CLIPlugin.d.ts.map +1 -0
- package/dist/src/plugin/CLIPlugin.js +2 -0
- package/dist/src/plugin/CommandFactory.d.ts +23 -0
- package/dist/src/plugin/CommandFactory.d.ts.map +1 -0
- package/dist/src/plugin/CommandFactory.js +7 -0
- package/dist/src/plugin/ServiceProviderFactory.d.ts +25 -0
- package/dist/src/plugin/ServiceProviderFactory.d.ts.map +1 -0
- package/dist/src/plugin/ServiceProviderFactory.js +7 -0
- package/dist/src/plugin/createCLIPlugin.d.ts +14 -0
- package/dist/src/plugin/createCLIPlugin.d.ts.map +1 -0
- package/dist/src/plugin/createCLIPlugin.js +30 -0
- package/dist/src/registry/CommandRegistry.d.ts +89 -0
- package/dist/src/registry/CommandRegistry.d.ts.map +1 -0
- package/dist/src/registry/CommandRegistry.js +0 -0
- package/dist/src/registry/ServiceProviderRegistry.d.ts +11 -0
- package/dist/src/registry/ServiceProviderRegistry.d.ts.map +1 -0
- package/dist/src/registry/ServiceProviderRegistry.js +0 -0
- package/dist/src/service/ServiceProvider.d.ts +47 -0
- package/dist/src/service/ServiceProvider.d.ts.map +1 -0
- package/dist/src/service/ServiceProvider.js +0 -0
- package/dist/src/service/core/ArgumentPrompterService.d.ts +6 -0
- package/dist/src/service/core/ArgumentPrompterService.d.ts.map +1 -0
- package/dist/src/service/core/ArgumentPrompterService.js +1 -0
- package/dist/src/service/core/AsciiBannerGeneratorService.d.ts +59 -0
- package/dist/src/service/core/AsciiBannerGeneratorService.d.ts.map +1 -0
- package/dist/src/service/core/AsciiBannerGeneratorService.js +1 -0
- package/dist/src/service/core/CompletionService.d.ts +22 -0
- package/dist/src/service/core/CompletionService.d.ts.map +1 -0
- package/dist/src/service/core/CompletionService.js +8 -0
- package/dist/src/service/core/DataDumpGeneratorService.d.ts +22 -0
- package/dist/src/service/core/DataDumpGeneratorService.d.ts.map +1 -0
- package/dist/src/service/core/DataDumpGeneratorService.js +7 -0
- package/dist/src/service/core/ImagePrinterService.d.ts +21 -0
- package/dist/src/service/core/ImagePrinterService.d.ts.map +1 -0
- package/dist/src/service/core/ImagePrinterService.js +1 -0
- package/dist/src/service/core/KeyValueService.d.ts +40 -0
- package/dist/src/service/core/KeyValueService.d.ts.map +1 -0
- package/dist/src/service/core/KeyValueService.js +7 -0
- package/dist/src/service/core/PluginService.d.ts +56 -0
- package/dist/src/service/core/PluginService.d.ts.map +1 -0
- package/dist/src/service/core/PluginService.js +6 -0
- package/dist/src/service/core/PrettyPrinterService.d.ts +35 -0
- package/dist/src/service/core/PrettyPrinterService.d.ts.map +1 -0
- package/dist/src/service/core/PrettyPrinterService.js +1 -0
- package/dist/src/service/core/PrinterService.d.ts +380 -0
- package/dist/src/service/core/PrinterService.d.ts.map +1 -0
- package/dist/src/service/core/PrinterService.js +42 -0
- package/dist/src/service/core/PrompterService.d.ts +35 -0
- package/dist/src/service/core/PrompterService.d.ts.map +1 -0
- package/dist/src/service/core/PrompterService.js +10 -0
- package/dist/src/service/core/SecretService.d.ts +25 -0
- package/dist/src/service/core/SecretService.d.ts.map +1 -0
- package/dist/src/service/core/SecretService.js +0 -0
- package/dist/src/service/core/ShutdownService.d.ts +24 -0
- package/dist/src/service/core/ShutdownService.d.ts.map +1 -0
- package/dist/src/service/core/ShutdownService.js +1 -0
- package/dist/src/service/core/SyntaxHighlighterService.d.ts +49 -0
- package/dist/src/service/core/SyntaxHighlighterService.d.ts.map +1 -0
- package/dist/src/service/core/SyntaxHighlighterService.js +1 -0
- package/dist/src/service/core/Table.d.ts +18 -0
- package/dist/src/service/core/Table.d.ts.map +1 -0
- package/dist/src/service/core/Table.js +49 -0
- package/dist/src/service/core/TableGeneratorService.d.ts +32 -0
- package/dist/src/service/core/TableGeneratorService.d.ts.map +1 -0
- package/dist/src/service/core/TableGeneratorService.js +7 -0
- package/dist/src/service/core/TreePrinterService.d.ts +9 -0
- package/dist/src/service/core/TreePrinterService.d.ts.map +1 -0
- package/dist/src/service/core/TreePrinterService.js +1 -0
- package/index.ts +138 -0
- package/package.json +66 -0
- package/src/CLI.ts +17 -0
- package/src/CLIConfig.ts +24 -0
- package/src/Context.ts +25 -0
- package/src/ParseResult.ts +40 -0
- package/src/RunResult.ts +158 -0
- package/src/argument/Argument.ts +75 -0
- package/src/argument/ArgumentValueTypes.ts +80 -0
- package/src/argument/ComplexOption.ts +27 -0
- package/src/argument/GlobalCommandArgument.ts +17 -0
- package/src/argument/Option.ts +32 -0
- package/src/argument/Positional.ts +27 -0
- package/src/argument/SubCommandArgument.ts +20 -0
- package/src/command/Command.ts +28 -0
- package/src/command/GlobalCommand.ts +30 -0
- package/src/command/GlobalModifierCommand.ts +12 -0
- package/src/command/GroupCommand.ts +20 -0
- package/src/command/SubCommand.ts +41 -0
- package/src/command/UsageExample.ts +21 -0
- package/src/plugin/CLIPlugin.ts +36 -0
- package/src/plugin/CommandFactory.ts +25 -0
- package/src/plugin/ServiceProviderFactory.ts +27 -0
- package/src/plugin/createCLIPlugin.ts +47 -0
- package/src/registry/CommandRegistry.ts +116 -0
- package/src/registry/ServiceProviderRegistry.ts +11 -0
- package/src/service/ServiceProvider.ts +52 -0
- package/src/service/core/ArgumentPrompterService.ts +8 -0
- package/src/service/core/AsciiBannerGeneratorService.ts +69 -0
- package/src/service/core/CompletionService.ts +32 -0
- package/src/service/core/DataDumpGeneratorService.ts +27 -0
- package/src/service/core/ImagePrinterService.ts +25 -0
- package/src/service/core/KeyValueService.ts +44 -0
- package/src/service/core/PluginService.ts +64 -0
- package/src/service/core/PrettyPrinterService.ts +39 -0
- package/src/service/core/PrinterService.ts +446 -0
- package/src/service/core/PrompterService.ts +42 -0
- package/src/service/core/SecretService.ts +27 -0
- package/src/service/core/ShutdownService.ts +27 -0
- package/src/service/core/SyntaxHighlighterService.ts +54 -0
- package/src/service/core/Table.ts +67 -0
- package/src/service/core/TableGeneratorService.ts +39 -0
- package/src/service/core/TreePrinterService.ts +10 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default class Table {
|
|
2
|
+
rowCount;
|
|
3
|
+
columnCount;
|
|
4
|
+
options;
|
|
5
|
+
#columnOptions = new Map();
|
|
6
|
+
#rowOptions = new Map();
|
|
7
|
+
#cells = new Map();
|
|
8
|
+
constructor(rowCount, columnCount, options) {
|
|
9
|
+
this.rowCount = rowCount;
|
|
10
|
+
this.columnCount = columnCount;
|
|
11
|
+
this.options = options ?? {};
|
|
12
|
+
}
|
|
13
|
+
row(rowIndex, rowOptions) {
|
|
14
|
+
if (rowIndex < 0 || rowIndex >= this.rowCount) {
|
|
15
|
+
throw new Error(`Row index ${rowIndex} out of bounds [0, ${this.rowCount})`);
|
|
16
|
+
}
|
|
17
|
+
this.#rowOptions.set(rowIndex, rowOptions);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
column(columnIndex, columnOptions) {
|
|
21
|
+
if (columnIndex < 0 || columnIndex >= this.columnCount) {
|
|
22
|
+
throw new Error(`Column index ${columnIndex} out of bounds [0, ${this.columnCount})`);
|
|
23
|
+
}
|
|
24
|
+
this.#columnOptions.set(columnIndex, columnOptions);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
cell(rowIndex, columnIndex, contents, cellOptions) {
|
|
28
|
+
if (rowIndex < 0 || rowIndex >= this.rowCount) {
|
|
29
|
+
throw new Error(`Row index ${rowIndex} out of bounds [0, ${this.rowCount})`);
|
|
30
|
+
}
|
|
31
|
+
if (columnIndex < 0 || columnIndex >= this.columnCount) {
|
|
32
|
+
throw new Error(`Column index ${columnIndex} out of bounds [0, ${this.columnCount})`);
|
|
33
|
+
}
|
|
34
|
+
this.#cells.set(`${rowIndex},${columnIndex}`, {
|
|
35
|
+
contents,
|
|
36
|
+
options: cellOptions,
|
|
37
|
+
});
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
getColumnOptions(columnIndex) {
|
|
41
|
+
return this.#columnOptions.get(columnIndex);
|
|
42
|
+
}
|
|
43
|
+
getRowOptions(rowIndex) {
|
|
44
|
+
return this.#rowOptions.get(rowIndex);
|
|
45
|
+
}
|
|
46
|
+
getCell(rowIndex, columnIndex) {
|
|
47
|
+
return this.#cells.get(`${rowIndex},${columnIndex}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const TABLE_GENERATOR_SERVICE_ID = "@flowscripter/dynamic-cli-framework/table-generator-service";
|
|
2
|
+
export declare enum Align {
|
|
3
|
+
LEFT = 0,
|
|
4
|
+
CENTER = 1,
|
|
5
|
+
RIGHT = 2
|
|
6
|
+
}
|
|
7
|
+
export interface TableOptions {
|
|
8
|
+
border?: boolean;
|
|
9
|
+
borderColor?: string;
|
|
10
|
+
borderBackgroundColor?: string;
|
|
11
|
+
padding?: number;
|
|
12
|
+
maxWidth?: number;
|
|
13
|
+
align?: Align;
|
|
14
|
+
}
|
|
15
|
+
export interface ColumnOptions {
|
|
16
|
+
flexWeight?: number;
|
|
17
|
+
minWidth?: number;
|
|
18
|
+
maxWidth?: number;
|
|
19
|
+
align?: Align;
|
|
20
|
+
}
|
|
21
|
+
export interface RowOptions {
|
|
22
|
+
align?: Align;
|
|
23
|
+
}
|
|
24
|
+
export interface CellOptions {
|
|
25
|
+
align?: Align;
|
|
26
|
+
}
|
|
27
|
+
export default interface TableGeneratorService {
|
|
28
|
+
createTable(rowCount: number, columnCount: number, options?: TableOptions): Table;
|
|
29
|
+
render(table: Table): string;
|
|
30
|
+
}
|
|
31
|
+
import type Table from "./Table.ts";
|
|
32
|
+
//# sourceMappingURL=TableGeneratorService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableGeneratorService.d.ts","sourceRoot":"","sources":["../../../../src/service/core/TableGeneratorService.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,gEACwB,CAAC;AAEhE,oBAAY,KAAK;IACf,IAAI,IAAI;IACR,MAAM,IAAI;IACV,KAAK,IAAI;CACV;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,CAAC,OAAO,WAAW,qBAAqB;IAC5C,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC;IAClF,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;CAC9B;AAED,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const TABLE_GENERATOR_SERVICE_ID = "@flowscripter/dynamic-cli-framework/table-generator-service";
|
|
2
|
+
export var Align;
|
|
3
|
+
(function (Align) {
|
|
4
|
+
Align[Align["LEFT"] = 0] = "LEFT";
|
|
5
|
+
Align[Align["CENTER"] = 1] = "CENTER";
|
|
6
|
+
Align[Align["RIGHT"] = 2] = "RIGHT";
|
|
7
|
+
})(Align || (Align = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const TREE_PRINTER_SERVICE_ID = "@flowscripter/dynamic-cli-framework/tree-printer-service";
|
|
2
|
+
export interface TreeNode {
|
|
3
|
+
label: string;
|
|
4
|
+
children?: Array<TreeNode | string>;
|
|
5
|
+
}
|
|
6
|
+
export default interface TreePrinterService {
|
|
7
|
+
print(node: TreeNode): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=TreePrinterService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreePrinterService.d.ts","sourceRoot":"","sources":["../../../../src/service/core/TreePrinterService.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,6DAA6D,CAAC;AAElG,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,CAAC,OAAO,WAAW,kBAAkB;IACzC,KAAK,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TREE_PRINTER_SERVICE_ID = "@flowscripter/dynamic-cli-framework/tree-printer-service";
|
package/index.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Argument API
|
|
2
|
+
export type { default as Argument } from "./src/argument/Argument.ts";
|
|
3
|
+
export type {
|
|
4
|
+
ArgumentSingleValueType,
|
|
5
|
+
ArgumentValues,
|
|
6
|
+
ArgumentValueType,
|
|
7
|
+
PopulatedArgumentSingleValueType,
|
|
8
|
+
PopulatedArgumentValues,
|
|
9
|
+
PopulatedArgumentValueType,
|
|
10
|
+
} from "./src/argument/ArgumentValueTypes.ts";
|
|
11
|
+
export { ArgumentValueTypeName, ComplexValueTypeName } from "./src/argument/ArgumentValueTypes.ts";
|
|
12
|
+
export type { default as ComplexOption } from "./src/argument/ComplexOption.ts";
|
|
13
|
+
export { MAXIMUM_COMPLEX_OPTION_NESTING_DEPTH } from "./src/argument/ComplexOption.ts";
|
|
14
|
+
export type { default as SubCommandArgument } from "./src/argument/SubCommandArgument.ts";
|
|
15
|
+
export { MAXIMUM_ARGUMENT_ARRAY_SIZE } from "./src/argument/SubCommandArgument.ts";
|
|
16
|
+
export type { default as GlobalCommandArgument } from "./src/argument/GlobalCommandArgument.ts";
|
|
17
|
+
export type { default as Option } from "./src/argument/Option.ts";
|
|
18
|
+
export type { default as Positional } from "./src/argument/Positional.ts";
|
|
19
|
+
|
|
20
|
+
// Command API
|
|
21
|
+
export type { default as Command } from "./src/command/Command.ts";
|
|
22
|
+
export type { default as GlobalCommand } from "./src/command/GlobalCommand.ts";
|
|
23
|
+
export type { default as GlobalModifierCommand } from "./src/command/GlobalModifierCommand.ts";
|
|
24
|
+
export type { default as GroupCommand } from "./src/command/GroupCommand.ts";
|
|
25
|
+
export type { default as SubCommand } from "./src/command/SubCommand.ts";
|
|
26
|
+
export type { default as UsageExample } from "./src/command/UsageExample.ts";
|
|
27
|
+
|
|
28
|
+
// Service API
|
|
29
|
+
export type { ServiceInfo, ServiceProvider } from "./src/service/ServiceProvider.ts";
|
|
30
|
+
|
|
31
|
+
// Registry API
|
|
32
|
+
export type { default as CommandRegistry } from "./src/registry/CommandRegistry.ts";
|
|
33
|
+
export type { default as ServiceProviderRegistry } from "./src/registry/ServiceProviderRegistry.ts";
|
|
34
|
+
|
|
35
|
+
// Core Service IDs and types
|
|
36
|
+
export { ASCII_BANNER_GENERATOR_SERVICE_ID } from "./src/service/core/AsciiBannerGeneratorService.ts";
|
|
37
|
+
export type { default as AsciiBannerGeneratorService } from "./src/service/core/AsciiBannerGeneratorService.ts";
|
|
38
|
+
export type {
|
|
39
|
+
BannerColorEffects,
|
|
40
|
+
BannerGenerateOptions,
|
|
41
|
+
ColorEffect,
|
|
42
|
+
ColorEffectDirection,
|
|
43
|
+
FixedColorEffect,
|
|
44
|
+
GradientColorEffect,
|
|
45
|
+
RainbowColorEffect,
|
|
46
|
+
} from "./src/service/core/AsciiBannerGeneratorService.ts";
|
|
47
|
+
|
|
48
|
+
export { KEY_VALUE_SERVICE_ID } from "./src/service/core/KeyValueService.ts";
|
|
49
|
+
export { SECRET_SENTINEL_PREFIX } from "./src/service/core/KeyValueService.ts";
|
|
50
|
+
export type { default as KeyValueService } from "./src/service/core/KeyValueService.ts";
|
|
51
|
+
export type { default as SecretService } from "./src/service/core/SecretService.ts";
|
|
52
|
+
|
|
53
|
+
export { PRINTER_SERVICE_ID } from "./src/service/core/PrinterService.ts";
|
|
54
|
+
export type { default as PrinterService } from "./src/service/core/PrinterService.ts";
|
|
55
|
+
export { Icon, Level, ProgressStyle, SpinnerStyle } from "./src/service/core/PrinterService.ts";
|
|
56
|
+
|
|
57
|
+
export { SHUTDOWN_SERVICE_ID } from "./src/service/core/ShutdownService.ts";
|
|
58
|
+
export type { default as ShutdownService } from "./src/service/core/ShutdownService.ts";
|
|
59
|
+
|
|
60
|
+
export { SYNTAX_HIGHLIGHTER_SERVICE_ID } from "./src/service/core/SyntaxHighlighterService.ts";
|
|
61
|
+
export type { default as SyntaxHighlighterService } from "./src/service/core/SyntaxHighlighterService.ts";
|
|
62
|
+
export type { ColorScheme } from "./src/service/core/SyntaxHighlighterService.ts";
|
|
63
|
+
|
|
64
|
+
export { PRETTY_PRINTER_SERVICE_ID } from "./src/service/core/PrettyPrinterService.ts";
|
|
65
|
+
export type { default as PrettyPrinterService } from "./src/service/core/PrettyPrinterService.ts";
|
|
66
|
+
|
|
67
|
+
export { IMAGE_PRINTER_SERVICE_ID } from "./src/service/core/ImagePrinterService.ts";
|
|
68
|
+
export type { default as ImagePrinterService } from "./src/service/core/ImagePrinterService.ts";
|
|
69
|
+
|
|
70
|
+
export { TREE_PRINTER_SERVICE_ID } from "./src/service/core/TreePrinterService.ts";
|
|
71
|
+
export type { default as TreePrinterService } from "./src/service/core/TreePrinterService.ts";
|
|
72
|
+
export type { TreeNode } from "./src/service/core/TreePrinterService.ts";
|
|
73
|
+
|
|
74
|
+
export { TABLE_GENERATOR_SERVICE_ID } from "./src/service/core/TableGeneratorService.ts";
|
|
75
|
+
export type { default as TableGeneratorService } from "./src/service/core/TableGeneratorService.ts";
|
|
76
|
+
export {
|
|
77
|
+
Align,
|
|
78
|
+
type CellOptions,
|
|
79
|
+
type ColumnOptions,
|
|
80
|
+
type RowOptions,
|
|
81
|
+
type TableOptions,
|
|
82
|
+
} from "./src/service/core/TableGeneratorService.ts";
|
|
83
|
+
export { default as Table } from "./src/service/core/Table.ts";
|
|
84
|
+
|
|
85
|
+
export { DATA_DUMP_GENERATOR_SERVICE_ID } from "./src/service/core/DataDumpGeneratorService.ts";
|
|
86
|
+
export type { default as DataDumpGeneratorService } from "./src/service/core/DataDumpGeneratorService.ts";
|
|
87
|
+
export {
|
|
88
|
+
type ByteRangeColor,
|
|
89
|
+
DumpFormat,
|
|
90
|
+
type HexDumpGenerateOptions,
|
|
91
|
+
} from "./src/service/core/DataDumpGeneratorService.ts";
|
|
92
|
+
|
|
93
|
+
export { COMPLETION_SERVICE_ID } from "./src/service/core/CompletionService.ts";
|
|
94
|
+
export type { default as CompletionService } from "./src/service/core/CompletionService.ts";
|
|
95
|
+
export { type CompletionItem, ShellType } from "./src/service/core/CompletionService.ts";
|
|
96
|
+
|
|
97
|
+
export { PROMPTER_SERVICE_ID } from "./src/service/core/PrompterService.ts";
|
|
98
|
+
export type { default as PrompterService } from "./src/service/core/PrompterService.ts";
|
|
99
|
+
export {
|
|
100
|
+
type Prompt,
|
|
101
|
+
type PromptOption,
|
|
102
|
+
type PromptResult,
|
|
103
|
+
PromptType,
|
|
104
|
+
} from "./src/service/core/PrompterService.ts";
|
|
105
|
+
|
|
106
|
+
export { ARGUMENT_PROMPTER_SERVICE_ID } from "./src/service/core/ArgumentPrompterService.ts";
|
|
107
|
+
export type { default as ArgumentPrompterService } from "./src/service/core/ArgumentPrompterService.ts";
|
|
108
|
+
export type { ParseResult } from "./src/ParseResult.ts";
|
|
109
|
+
|
|
110
|
+
// CLI API
|
|
111
|
+
export type { InvalidArgument } from "./src/RunResult.ts";
|
|
112
|
+
export type { default as Context } from "./src/Context.ts";
|
|
113
|
+
export type { default as RunResult } from "./src/RunResult.ts";
|
|
114
|
+
export { InvalidArgumentReason, RunState } from "./src/RunResult.ts";
|
|
115
|
+
export type { default as CLIConfig } from "./src/CLIConfig.ts";
|
|
116
|
+
export type { default as CLI } from "./src/CLI.ts";
|
|
117
|
+
|
|
118
|
+
// Plugin API
|
|
119
|
+
export type { default as CommandFactory } from "./src/plugin/CommandFactory.ts";
|
|
120
|
+
export { DYNAMIC_CLI_FRAMEWORK_COMMAND_FACTORY_EXTENSION_POINT } from "./src/plugin/CommandFactory.ts";
|
|
121
|
+
export type { default as ServiceProviderFactory } from "./src/plugin/ServiceProviderFactory.ts";
|
|
122
|
+
export { DYNAMIC_CLI_FRAMEWORK_SERVICE_PROVIDER_FACTORY_EXTENSION_POINT } from "./src/plugin/ServiceProviderFactory.ts";
|
|
123
|
+
export type {
|
|
124
|
+
Plugin,
|
|
125
|
+
ExtensionDescriptor,
|
|
126
|
+
ExtensionFactory,
|
|
127
|
+
VersionedPluginDescriptor,
|
|
128
|
+
SearchQuery,
|
|
129
|
+
} from "@flowscripter/dynamic-plugin-framework";
|
|
130
|
+
export type {
|
|
131
|
+
default as CLIPlugin,
|
|
132
|
+
CommandFactoryExtensionDescriptor,
|
|
133
|
+
ServiceProviderFactoryExtensionDescriptor,
|
|
134
|
+
} from "./src/plugin/CLIPlugin.ts";
|
|
135
|
+
export { default as createCLIPlugin } from "./src/plugin/createCLIPlugin.ts";
|
|
136
|
+
export type { CLIPluginOptions } from "./src/plugin/createCLIPlugin.ts";
|
|
137
|
+
export { PLUGIN_SERVICE_ID } from "./src/service/core/PluginService.ts";
|
|
138
|
+
export type { default as PluginService } from "./src/service/core/PluginService.ts";
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flowscripter/dynamic-cli-framework-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "API for https://github.com/flowscripter/dynamic-cli-framework",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bun",
|
|
7
|
+
"cli",
|
|
8
|
+
"dynamic",
|
|
9
|
+
"dynamic-cli-framework",
|
|
10
|
+
"framework",
|
|
11
|
+
"import",
|
|
12
|
+
"plugin"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/flowscripter/dynamic-cli-framework-api#readme",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/flowscripter/dynamic-cli-framework-api.git"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src",
|
|
23
|
+
"index.ts",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"module": "dist/index.js",
|
|
30
|
+
"types": "dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"bun": "./index.ts",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc -p tsconfig.build.json"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@flowscripter/dynamic-plugin-framework": "1.10.1",
|
|
46
|
+
"@types/bun": "^1.3.14",
|
|
47
|
+
"highlight.js": "^11.11.1",
|
|
48
|
+
"oxfmt": "0.57.0",
|
|
49
|
+
"oxlint": "1.72.0",
|
|
50
|
+
"prettier": "^3.9.5"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"typescript": "^6.0.3"
|
|
54
|
+
},
|
|
55
|
+
"typedocOptions": {
|
|
56
|
+
"readme": "none",
|
|
57
|
+
"exclude": [
|
|
58
|
+
"tests/**"
|
|
59
|
+
],
|
|
60
|
+
"externalSymbolLinkMappings": {
|
|
61
|
+
"@flowscripter/dynamic-plugin-framework": {
|
|
62
|
+
"default": "https://flowscripter.github.io/dynamic-plugin-framework/interfaces/PluginDescriptor.html"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/CLI.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface to be implemented by a CLI application.
|
|
3
|
+
*/
|
|
4
|
+
import type RunResult from "./RunResult.ts";
|
|
5
|
+
import type CLIConfig from "./CLIConfig.ts";
|
|
6
|
+
|
|
7
|
+
export default interface CLI {
|
|
8
|
+
/**
|
|
9
|
+
* Run the CLI with the provided arguments which do not include the invoked executable name.
|
|
10
|
+
*
|
|
11
|
+
* @param args the arguments to parse.
|
|
12
|
+
* @param cliConfig the {@link CLIConfig} for the CLI application.
|
|
13
|
+
*
|
|
14
|
+
* @return result of parsing arguments and running appropriate {@link Command} instances.
|
|
15
|
+
*/
|
|
16
|
+
run(args: ReadonlyArray<string>, cliConfig: CLIConfig): Promise<RunResult>;
|
|
17
|
+
}
|
package/src/CLIConfig.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface specifying common configuration for a {@link CLI} application.
|
|
3
|
+
*/
|
|
4
|
+
export default interface CLIConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Name of the CLI application.
|
|
7
|
+
*/
|
|
8
|
+
readonly name: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Optional description of the CLI application.
|
|
12
|
+
*/
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Optional sub-message to display below the banner.
|
|
17
|
+
*/
|
|
18
|
+
readonly subMessage?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Version of the CLI application.
|
|
22
|
+
*/
|
|
23
|
+
readonly version: string;
|
|
24
|
+
}
|
package/src/Context.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface allowing a {@link CLI} to pass context to a {@link Command} instance.
|
|
3
|
+
*/
|
|
4
|
+
import type CLIConfig from "./CLIConfig.ts";
|
|
5
|
+
|
|
6
|
+
export default interface Context {
|
|
7
|
+
/**
|
|
8
|
+
* The {@link CLIConfig} in use by the {@link CLI}.
|
|
9
|
+
*/
|
|
10
|
+
readonly cliConfig: CLIConfig;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Return the service identified by the specified ID.
|
|
14
|
+
*
|
|
15
|
+
* @param id the ID of the service to retrieve.
|
|
16
|
+
*/
|
|
17
|
+
getServiceById(id: string): unknown;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Check if the specified service exists in the context.
|
|
21
|
+
*
|
|
22
|
+
* @param id the ID of the desired service.
|
|
23
|
+
*/
|
|
24
|
+
doesServiceExist(id: string): boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type Command from "./command/Command.ts";
|
|
2
|
+
import type GroupCommand from "./command/GroupCommand.ts";
|
|
3
|
+
import type {
|
|
4
|
+
PopulatedArgumentSingleValueType,
|
|
5
|
+
PopulatedArgumentValues,
|
|
6
|
+
} from "./argument/ArgumentValueTypes.ts";
|
|
7
|
+
import type { InvalidArgument } from "./RunResult.ts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A container holding the result of a command clause parsing operation.
|
|
11
|
+
*/
|
|
12
|
+
export interface ParseResult {
|
|
13
|
+
/**
|
|
14
|
+
* The {@link Command} to execute if the parse result is valid (i.e. {@link invalidArguments} is empty).
|
|
15
|
+
*/
|
|
16
|
+
readonly command: Command;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Optional parent {@link GroupCommand} if the parsed {@link command} was a member {@link SubCommand},
|
|
20
|
+
*/
|
|
21
|
+
readonly groupCommand?: GroupCommand;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The argument values populated from the command line args. If the parse result is valid
|
|
25
|
+
* (i.e. {@link invalidArguments} is empty), this can be used to execute the specified {@link command}.
|
|
26
|
+
* {@link PopulatedArgumentSingleValueType} is for {@link GlobalCommand} values, {@link PopulatedArgumentValues} is for
|
|
27
|
+
* {@link SubCommand} values.
|
|
28
|
+
*/
|
|
29
|
+
readonly populatedArgumentValues: PopulatedArgumentValues | PopulatedArgumentSingleValueType;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Any arguments which were invalid.
|
|
33
|
+
*/
|
|
34
|
+
readonly invalidArguments: ReadonlyArray<InvalidArgument>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Any arguments which were unused in the parsing operation.
|
|
38
|
+
*/
|
|
39
|
+
readonly unusedArgs: ReadonlyArray<string>;
|
|
40
|
+
}
|
package/src/RunResult.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State of a {@link CLI} after invocation.
|
|
3
|
+
*/
|
|
4
|
+
import type Command from "./command/Command.ts";
|
|
5
|
+
import type Argument from "./argument/Argument.ts";
|
|
6
|
+
import type ComplexOption from "./argument/ComplexOption.ts";
|
|
7
|
+
import type {
|
|
8
|
+
PopulatedArgumentValues,
|
|
9
|
+
PopulatedArgumentValueType,
|
|
10
|
+
} from "./argument/ArgumentValueTypes.ts";
|
|
11
|
+
|
|
12
|
+
export enum RunState {
|
|
13
|
+
/**
|
|
14
|
+
* Arguments were successfully parsed and the specified command(s) were successfully executed.
|
|
15
|
+
*/
|
|
16
|
+
SUCCESS = 0,
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The arguments supplied were invalid or could not be parsed.
|
|
20
|
+
*/
|
|
21
|
+
PARSE_ERROR = 1,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Arguments were successfully parsed but no command was discovered.
|
|
25
|
+
*/
|
|
26
|
+
NO_COMMAND = 2,
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Arguments were successfully parsed and command(s) discovered but command execution failed.
|
|
30
|
+
*/
|
|
31
|
+
EXECUTION_ERROR = 3,
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* General runtime error related to the framework.
|
|
35
|
+
*/
|
|
36
|
+
RUNTIME_ERROR = 4,
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Execution was interrupted by a signal (e.g. Ctrl-C or SIGTERM).
|
|
40
|
+
*/
|
|
41
|
+
INTERRUPTED = 130,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Possible reasons for an invalid argument.
|
|
46
|
+
*/
|
|
47
|
+
export enum InvalidArgumentReason {
|
|
48
|
+
/**
|
|
49
|
+
* The argument value was not specified.
|
|
50
|
+
*/
|
|
51
|
+
MISSING_VALUE = 0,
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The value specified was not the correct type for the argument.
|
|
55
|
+
*/
|
|
56
|
+
INCORRECT_VALUE_TYPE = 1,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The argument does not support multiple values.
|
|
60
|
+
*/
|
|
61
|
+
ILLEGAL_MULTIPLE_VALUES = 2,
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The value specified was not one of the defined allowable values for the argument.
|
|
65
|
+
*/
|
|
66
|
+
ILLEGAL_VALUE = 3,
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The arguments specified resulted in a sparse array of values.
|
|
70
|
+
*/
|
|
71
|
+
ILLEGAL_SPARSE_ARRAY = 4,
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The argument specified an unknown complex option property.
|
|
75
|
+
*/
|
|
76
|
+
UNKNOWN_PROPERTY = 5,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Complex option nesting exceeds maximum of {@link MAXIMUM_COMPLEX_OPTION_NESTING_DEPTH}.
|
|
80
|
+
*/
|
|
81
|
+
NESTING_DEPTH_EXCEEDED = 6,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Array value nesting exceeds maximum of {@link MAXIMUM_ARGUMENT_ARRAY_SIZE}.
|
|
85
|
+
*/
|
|
86
|
+
ARRAY_SIZE_EXCEEDED = 7,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Attempt to set a primitive value on a complex object object.
|
|
90
|
+
*/
|
|
91
|
+
OPTION_IS_COMPLEX = 8,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The value failed a custom validation function defined on the argument.
|
|
95
|
+
*/
|
|
96
|
+
CUSTOM_VALIDATION = 9,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Details of an invalid parsed argument.
|
|
101
|
+
*/
|
|
102
|
+
export interface InvalidArgument {
|
|
103
|
+
/**
|
|
104
|
+
* A reason for the parsing error
|
|
105
|
+
*/
|
|
106
|
+
readonly reason: InvalidArgumentReason;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The name of the argument specified (if it was able to be populated)
|
|
110
|
+
*/
|
|
111
|
+
readonly name?: string;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The {@link Argument} (if it was able to be populated)
|
|
115
|
+
*/
|
|
116
|
+
readonly argument?: Argument | ComplexOption;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The argument value (if it was able to be populated).
|
|
120
|
+
*
|
|
121
|
+
* NOTE: This value is unlikely to be valid as it is the cause of the invalid argument error.
|
|
122
|
+
*/
|
|
123
|
+
readonly value?:
|
|
124
|
+
| PopulatedArgumentValues
|
|
125
|
+
| PopulatedArgumentValueType
|
|
126
|
+
| Array<PopulatedArgumentValues | PopulatedArgumentValueType>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* An optional message providing detail about the validation failure.
|
|
130
|
+
* Populated when {@link reason} is {@link InvalidArgumentReason.CUSTOM_VALIDATION}.
|
|
131
|
+
*/
|
|
132
|
+
readonly message?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Result of a {@link CLI} invocation.
|
|
137
|
+
*/
|
|
138
|
+
export default interface RunResult {
|
|
139
|
+
/**
|
|
140
|
+
* The state after processing the invocation.
|
|
141
|
+
*/
|
|
142
|
+
readonly runState: RunState;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Populated if {@link runState} is {@link RunState.SUCCESS}, {@link RunState.PARSE_ERROR} or {@link RunState.EXECUTION_ERROR}.
|
|
146
|
+
*/
|
|
147
|
+
readonly command?: Command;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Populated if {@link runState} is {@link RunState.PARSE_ERROR}
|
|
151
|
+
*/
|
|
152
|
+
readonly invalidArguments?: ReadonlyArray<InvalidArgument>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Populated if {@link runState} is {@link RunState.EXECUTION_ERROR} or {@link RunState.RUNTIME_ERROR}.
|
|
156
|
+
*/
|
|
157
|
+
readonly error?: Error;
|
|
158
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ArgumentSingleValueType,
|
|
3
|
+
ArgumentValues,
|
|
4
|
+
ArgumentValueType,
|
|
5
|
+
ArgumentValueTypeName,
|
|
6
|
+
} from "./ArgumentValueTypes.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Interface to be implemented by all {@link Command} arguments.
|
|
10
|
+
*/
|
|
11
|
+
export default interface Argument {
|
|
12
|
+
/**
|
|
13
|
+
* Type of the argument value.
|
|
14
|
+
*/
|
|
15
|
+
readonly type: ArgumentValueTypeName;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Optional list of values that the value must match. This is not supported for {@link ArgumentValueTypeName.BOOLEAN}.
|
|
19
|
+
*/
|
|
20
|
+
readonly allowableValues?: ReadonlyArray<ArgumentSingleValueType>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Optional (default is `false`) for {@link ArgumentValueTypeName.STRING} when comparing a value against {@link allowableValues}.
|
|
24
|
+
*/
|
|
25
|
+
readonly isCaseInsensitive?: boolean;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Optional for {@link ArgumentValueTypeName.INTEGER} or {@link ArgumentValueTypeName.NUMBER} when validating a value.
|
|
29
|
+
*/
|
|
30
|
+
readonly minValueInclusive?: number;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Optional for {@link ArgumentValueTypeName.INTEGER} or {@link ArgumentValueTypeName.NUMBER} when validating a value.
|
|
34
|
+
*/
|
|
35
|
+
readonly maxValueInclusive?: number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Optional configuration key to use for the argument. Must consist of alphanumeric non-whitespace uppercase
|
|
39
|
+
* ASCII or `_` characters. Must not start with a digit.
|
|
40
|
+
*
|
|
41
|
+
* If not specified a default configuration key is determined as follows: The {@link SubCommandArgument.name} is capitalized
|
|
42
|
+
* and any `-` characters are replaced with `_` characters. If the result starts with a digit, it is
|
|
43
|
+
* prefixed with `_`. Some examples:
|
|
44
|
+
*
|
|
45
|
+
* * name: `FooBar` => configuration key: `FOOBAR`
|
|
46
|
+
* * name: `Hello-World-` => configuration key: `HELLO_WORLD_`
|
|
47
|
+
* * name: `3` => configuration key: `_3`
|
|
48
|
+
*
|
|
49
|
+
* NOTE: Regardless of whether a {@link configurationKey} is specified, or the default is relied upon,
|
|
50
|
+
* it will only be used if the parent {@link Command} has specified {@link Command.enableConfiguration} as `true`.
|
|
51
|
+
*/
|
|
52
|
+
readonly configurationKey?: string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Optional custom validation function invoked after all built-in validation
|
|
56
|
+
* has passed. Receives the validated and type-converted value.
|
|
57
|
+
*
|
|
58
|
+
* Return `undefined` if the value is valid, or a string describing the
|
|
59
|
+
* validation error. The error string is associated with
|
|
60
|
+
* {@link InvalidArgumentReason.CUSTOM_VALIDATION}.
|
|
61
|
+
*
|
|
62
|
+
* Example: ensure array values are unique:
|
|
63
|
+
* ```typescript
|
|
64
|
+
* validate: (value) => {
|
|
65
|
+
* const arr = value as string[];
|
|
66
|
+
* return new Set(arr).size !== arr.length
|
|
67
|
+
* ? "values must be unique"
|
|
68
|
+
* : undefined;
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
readonly validate?: (
|
|
73
|
+
value: ArgumentValueType | ArgumentValues | Array<ArgumentValues>,
|
|
74
|
+
) => string | undefined;
|
|
75
|
+
}
|