@flowscripter/dynamic-cli-framework 2.5.0 → 3.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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/src/command/MultiCommandCliHelpCommand.d.ts +4 -4
- package/dist/src/command/MultiCommandCliHelpCommand.d.ts.map +1 -1
- package/dist/src/command/MultiCommandCliHelpCommand.js +3 -3
- package/dist/src/runtime/command/CommandValidator.d.ts.map +1 -1
- package/dist/src/runtime/command/CommandValidator.js +14 -16
- package/dist/src/runtime/parser.d.ts +5 -5
- package/dist/src/runtime/parser.d.ts.map +1 -1
- package/dist/src/runtime/parser.js +2 -2
- package/dist/src/runtime/runner.d.ts.map +1 -1
- package/dist/src/runtime/values/ValuePopulationResult.d.ts +3 -3
- package/dist/src/runtime/values/ValuePopulationResult.d.ts.map +1 -1
- package/dist/src/runtime/values/argumentValueMerge.d.ts +2 -2
- package/dist/src/runtime/values/argumentValueMerge.d.ts.map +1 -1
- package/dist/src/runtime/values/argumentValueValidation.d.ts +4 -4
- package/dist/src/runtime/values/argumentValueValidation.d.ts.map +1 -1
- package/dist/src/runtime/values/argumentValueValidation.js +6 -6
- package/dist/src/runtime/values/globalCommandValuePopulation.d.ts +4 -4
- package/dist/src/runtime/values/globalCommandValuePopulation.d.ts.map +1 -1
- package/dist/src/runtime/values/globalCommandValuePopulation.js +5 -5
- package/dist/src/runtime/values/subCommandValuePopulation.d.ts +5 -5
- package/dist/src/runtime/values/subCommandValuePopulation.d.ts.map +1 -1
- package/dist/src/runtime/values/subCommandValuePopulation.js +8 -7
- package/dist/src/service/argumentPrompter/DefaultArgumentPrompterService.d.ts.map +1 -1
- package/dist/src/service/argumentPrompter/DefaultArgumentPrompterService.js +6 -6
- package/dist/src/service/banner/command/NoBannerCommand.d.ts +2 -2
- package/dist/src/service/banner/command/NoBannerCommand.d.ts.map +1 -1
- package/dist/src/service/banner/command/NoBannerCommand.js +2 -2
- package/dist/src/service/completion/command/CompletionCompleteSubCommand.d.ts +2 -2
- package/dist/src/service/completion/command/CompletionCompleteSubCommand.d.ts.map +1 -1
- package/dist/src/service/completion/command/CompletionCompleteSubCommand.js +3 -3
- package/dist/src/service/completion/command/CompletionIntegrationSubCommand.d.ts +2 -2
- package/dist/src/service/completion/command/CompletionIntegrationSubCommand.d.ts.map +1 -1
- package/dist/src/service/completion/command/CompletionIntegrationSubCommand.js +3 -3
- package/dist/src/service/configuration/ConfigurationServiceProvider.d.ts +6 -6
- package/dist/src/service/configuration/ConfigurationServiceProvider.d.ts.map +1 -1
- package/dist/src/service/configuration/ConfigurationServiceProvider.js +4 -4
- package/dist/src/service/configuration/command/ConfigCommand.d.ts +2 -2
- package/dist/src/service/configuration/command/ConfigCommand.d.ts.map +1 -1
- package/dist/src/service/configuration/command/ConfigCommand.js +2 -2
- package/dist/src/service/plugin/command/PluginAddSubCommand.d.ts +4 -4
- package/dist/src/service/plugin/command/PluginAddSubCommand.d.ts.map +1 -1
- package/dist/src/service/plugin/command/PluginAddSubCommand.js +2 -2
- package/dist/src/service/plugin/command/PluginListSubCommand.d.ts +2 -2
- package/dist/src/service/plugin/command/PluginListSubCommand.d.ts.map +1 -1
- package/dist/src/service/plugin/command/PluginRemoveSubCommand.d.ts +4 -4
- package/dist/src/service/plugin/command/PluginRemoveSubCommand.d.ts.map +1 -1
- package/dist/src/service/plugin/command/PluginRemoveSubCommand.js +2 -2
- package/dist/src/service/plugin/command/PluginSearchSubCommand.d.ts +4 -4
- package/dist/src/service/plugin/command/PluginSearchSubCommand.d.ts.map +1 -1
- package/dist/src/service/plugin/command/PluginSearchSubCommand.js +2 -2
- package/dist/src/service/plugin/command/PluginUpgradeSubCommand.d.ts +2 -2
- package/dist/src/service/plugin/command/PluginUpgradeSubCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/DarkModeCommand.d.ts +2 -2
- package/dist/src/service/printer/command/DarkModeCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/DarkModeCommand.js +2 -2
- package/dist/src/service/printer/command/LogLevelCommand.d.ts +2 -2
- package/dist/src/service/printer/command/LogLevelCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/LogLevelCommand.js +2 -2
- package/dist/src/service/printer/command/NoColorCommand.d.ts +2 -2
- package/dist/src/service/printer/command/NoColorCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/NoColorCommand.js +2 -2
- package/dist/src/service/printer/command/NoHyperlinksCommand.d.ts +2 -2
- package/dist/src/service/printer/command/NoHyperlinksCommand.d.ts.map +1 -1
- package/dist/src/service/printer/command/NoHyperlinksCommand.js +2 -2
- package/dist/src/service/prompter/command/NoPromptCommand.d.ts +2 -2
- package/dist/src/service/prompter/command/NoPromptCommand.d.ts.map +1 -1
- package/dist/src/service/prompter/command/NoPromptCommand.js +2 -2
- package/dist/src/service/upgrade/command/UpgradeSubCommand.d.ts +2 -2
- package/dist/src/service/upgrade/command/UpgradeSubCommand.d.ts.map +1 -1
- package/dist/src/service/upgrade/command/UpgradeSubCommand.js +3 -3
- package/dist/src/util/envVarHelper.d.ts +3 -3
- package/dist/src/util/envVarHelper.d.ts.map +1 -1
- package/dist/src/util/envVarHelper.js +9 -12
- package/dist/src/util/helpHelper.d.ts.map +1 -1
- package/dist/src/util/helpHelper.js +27 -28
- package/index.ts +7 -10
- package/package.json +2 -2
- package/src/command/MultiCommandCliHelpCommand.ts +7 -7
- package/src/runtime/command/CommandValidator.ts +17 -26
- package/src/runtime/parser.ts +8 -8
- package/src/runtime/runner.ts +16 -19
- package/src/runtime/values/ValuePopulationResult.ts +4 -4
- package/src/runtime/values/argumentValueMerge.ts +33 -50
- package/src/runtime/values/argumentValueValidation.ts +38 -52
- package/src/runtime/values/globalCommandValuePopulation.ts +7 -7
- package/src/runtime/values/subCommandValuePopulation.ts +42 -47
- package/src/service/argumentPrompter/DefaultArgumentPrompterService.ts +23 -26
- package/src/service/banner/command/NoBannerCommand.ts +3 -6
- package/src/service/completion/command/CompletionCompleteSubCommand.ts +4 -7
- package/src/service/completion/command/CompletionIntegrationSubCommand.ts +4 -7
- package/src/service/configuration/ConfigurationServiceProvider.ts +21 -21
- package/src/service/configuration/command/ConfigCommand.ts +3 -6
- package/src/service/plugin/command/PluginAddSubCommand.ts +4 -4
- package/src/service/plugin/command/PluginListSubCommand.ts +2 -2
- package/src/service/plugin/command/PluginRemoveSubCommand.ts +4 -4
- package/src/service/plugin/command/PluginSearchSubCommand.ts +4 -4
- package/src/service/plugin/command/PluginUpgradeSubCommand.ts +2 -2
- package/src/service/printer/command/DarkModeCommand.ts +3 -6
- package/src/service/printer/command/LogLevelCommand.ts +3 -6
- package/src/service/printer/command/NoColorCommand.ts +3 -6
- package/src/service/printer/command/NoHyperlinksCommand.ts +3 -6
- package/src/service/prompter/command/NoPromptCommand.ts +3 -6
- package/src/service/prompter/prompt/promptText.ts +2 -2
- package/src/service/upgrade/command/UpgradeSubCommand.ts +4 -7
- package/src/util/envVarHelper.ts +23 -26
- package/src/util/helpHelper.ts +28 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoPromptCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/prompter/command/NoPromptCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,
|
|
1
|
+
{"version":3,"file":"NoPromptCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/prompter/command/NoPromptCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,KAAK,uBAAuB,MAAM,+BAA+B,CAAC;AAEzE,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,qBAAqB;;IACnE,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,WAAW,mCAAmC;IACvD,QAAQ,CAAC,mBAAmB,QAAQ;IACpC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAItC;IACF,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;gBAId,uBAAuB,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM;IAKrF,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAKjF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
2
|
export default class NoPromptCommand {
|
|
3
3
|
name = "no-prompt";
|
|
4
4
|
description = "Disable interactive prompting";
|
|
5
5
|
enableConfiguration = true;
|
|
6
6
|
argument = {
|
|
7
|
-
type:
|
|
7
|
+
type: ValueTypeName.BOOLEAN,
|
|
8
8
|
defaultValue: false,
|
|
9
9
|
configurationKey: "NO_PROMPT",
|
|
10
10
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SubCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
2
|
import type { Option } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
import type { Context } from "@flowscripter/dynamic-cli-framework-api";
|
|
4
|
-
import { type
|
|
4
|
+
import { type Values } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
5
|
import type DefaultUpgradeService from "../DefaultUpgradeService.ts";
|
|
6
6
|
export declare class UpgradeSubCommand implements SubCommand {
|
|
7
7
|
#private;
|
|
@@ -11,6 +11,6 @@ export declare class UpgradeSubCommand implements SubCommand {
|
|
|
11
11
|
readonly positionals: never[];
|
|
12
12
|
readonly options: ReadonlyArray<Option>;
|
|
13
13
|
constructor(upgradeService: DefaultUpgradeService);
|
|
14
|
-
execute(context: Context, argumentValues:
|
|
14
|
+
execute(context: Context, argumentValues: Values): Promise<void>;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=UpgradeSubCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpgradeSubCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/upgrade/command/UpgradeSubCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,
|
|
1
|
+
{"version":3,"file":"UpgradeSubCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/upgrade/command/UpgradeSubCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,yCAAyC,CAAC;AASrF,OAAO,KAAK,qBAAqB,MAAM,6BAA6B,CAAC;AAErE,qBAAa,iBAAkB,YAAW,UAAU;;IAClD,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,WAAW,6CAA6C;IACjE,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,WAAW,UAAM;IAE1B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAerC;gBAIiB,cAAc,EAAE,qBAAqB;IAI3C,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAyC9E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
2
|
import { Icon, InstallMethod, PRINTER_SERVICE_ID, SupportedArch, SupportedOs, } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
export class UpgradeSubCommand {
|
|
4
4
|
name = "upgrade";
|
|
@@ -8,14 +8,14 @@ export class UpgradeSubCommand {
|
|
|
8
8
|
options = [
|
|
9
9
|
{
|
|
10
10
|
name: "os",
|
|
11
|
-
type:
|
|
11
|
+
type: ValueTypeName.STRING,
|
|
12
12
|
isOptional: true,
|
|
13
13
|
allowableValues: Object.values(SupportedOs),
|
|
14
14
|
description: "Override the detected operating system",
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
name: "install-method",
|
|
18
|
-
type:
|
|
18
|
+
type: ValueTypeName.STRING,
|
|
19
19
|
isOptional: true,
|
|
20
20
|
allowableValues: Object.values(InstallMethod),
|
|
21
21
|
description: "Override the detected install method",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CLIConfig } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
-
import { type
|
|
2
|
+
import { type PopulatedSingleValueType, type PopulatedValues } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
import type { GlobalCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
4
4
|
import type { SubCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
5
|
/**
|
|
@@ -9,7 +9,7 @@ import type { SubCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
|
9
9
|
* @param command the {@link GlobalCommand} to use for determining the default configuration key and containing a
|
|
10
10
|
* {@link GlobalCommandArgument} instance to populate a value for.
|
|
11
11
|
*/
|
|
12
|
-
export declare function getGlobalCommandValueFromEnvVars(cliConfig: CLIConfig, command: GlobalCommand):
|
|
12
|
+
export declare function getGlobalCommandValueFromEnvVars(cliConfig: CLIConfig, command: GlobalCommand): PopulatedSingleValueType;
|
|
13
13
|
/**
|
|
14
14
|
* Get configured argument values for the specified {@link Option} from environment variables.
|
|
15
15
|
*
|
|
@@ -17,5 +17,5 @@ export declare function getGlobalCommandValueFromEnvVars(cliConfig: CLIConfig, c
|
|
|
17
17
|
* @param command the {@link SubCommand} to use for determining the default configuration key and containing
|
|
18
18
|
* {@link Positional} and {@link Option} instances to populate values for.
|
|
19
19
|
*/
|
|
20
|
-
export declare function getSubCommandValuesFromEnvVars(cliConfig: CLIConfig, command: SubCommand):
|
|
20
|
+
export declare function getSubCommandValuesFromEnvVars(cliConfig: CLIConfig, command: SubCommand): PopulatedValues | undefined;
|
|
21
21
|
//# sourceMappingURL=envVarHelper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envVarHelper.d.ts","sourceRoot":"","sources":["../../../src/util/envVarHelper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAGL,KAAK,
|
|
1
|
+
{"version":3,"file":"envVarHelper.d.ts","sourceRoot":"","sources":["../../../src/util/envVarHelper.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACrB,MAAM,yCAAyC,CAAC;AAOjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAmC1E;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,aAAa,GACrB,wBAAwB,CAa1B;AAwID;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,UAAU,GAClB,eAAe,GAAG,SAAS,CA4E7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import {
|
|
2
|
+
import { ValueTypeName, ComplexValueTypeName, } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
import { MAXIMUM_ARGUMENT_ARRAY_SIZE } from "@flowscripter/dynamic-cli-framework-api";
|
|
4
4
|
function getKeySegment(segment) {
|
|
5
5
|
let keySegment = segment.replace("-", "_").toUpperCase();
|
|
@@ -34,7 +34,7 @@ export function getGlobalCommandValueFromEnvVars(cliConfig, command) {
|
|
|
34
34
|
}
|
|
35
35
|
// simple check for a specific env var name
|
|
36
36
|
let envVarValue = process.env[getGlobalArgumentKeyPrefix(cliConfig, command, argument)];
|
|
37
|
-
if (envVarValue != undefined && argument.type ===
|
|
37
|
+
if (envVarValue != undefined && argument.type === ValueTypeName.BOOLEAN) {
|
|
38
38
|
envVarValue = envVarValue.length > 0 ? "true" : "false";
|
|
39
39
|
}
|
|
40
40
|
return envVarValue;
|
|
@@ -77,8 +77,7 @@ function getOptionValuesFromEnvVars(envVarValues, potentialEnvVarNames, env, opt
|
|
|
77
77
|
}
|
|
78
78
|
if (suffix.length > 0) {
|
|
79
79
|
if (option.type === ComplexValueTypeName.COMPLEX) {
|
|
80
|
-
if (envVarValues[option.name][index] ===
|
|
81
|
-
undefined) {
|
|
80
|
+
if (envVarValues[option.name][index] === undefined) {
|
|
82
81
|
envVarValues[option.name][index] = Object.create(null);
|
|
83
82
|
}
|
|
84
83
|
option.properties.forEach((property) => {
|
|
@@ -99,11 +98,10 @@ function getOptionValuesFromEnvVars(envVarValues, potentialEnvVarNames, env, opt
|
|
|
99
98
|
else {
|
|
100
99
|
// set primitive value
|
|
101
100
|
let envVarValue = env[match];
|
|
102
|
-
if (envVarValue != undefined && option.type ===
|
|
101
|
+
if (envVarValue != undefined && option.type === ValueTypeName.BOOLEAN) {
|
|
103
102
|
envVarValue = envVarValue.length > 1 ? "true" : "false";
|
|
104
103
|
}
|
|
105
|
-
envVarValues[option.name][index] =
|
|
106
|
-
envVarValue;
|
|
104
|
+
envVarValues[option.name][index] = envVarValue;
|
|
107
105
|
}
|
|
108
106
|
const elements = envVarValues[option.name];
|
|
109
107
|
for (let i = elements.length - 1; i > -1; i--) {
|
|
@@ -135,7 +133,7 @@ function getOptionValuesFromEnvVars(envVarValues, potentialEnvVarNames, env, opt
|
|
|
135
133
|
if (value === undefined) {
|
|
136
134
|
return undefined;
|
|
137
135
|
}
|
|
138
|
-
if (option.type ===
|
|
136
|
+
if (option.type === ValueTypeName.BOOLEAN) {
|
|
139
137
|
value = value.length > 1 ? "true" : "false";
|
|
140
138
|
}
|
|
141
139
|
// set primitive value
|
|
@@ -186,11 +184,10 @@ export function getSubCommandValuesFromEnvVars(cliConfig, command) {
|
|
|
186
184
|
}
|
|
187
185
|
// set primitive value
|
|
188
186
|
let envVarValue = process.env[match];
|
|
189
|
-
if (envVarValue != undefined && positional.type ===
|
|
187
|
+
if (envVarValue != undefined && positional.type === ValueTypeName.BOOLEAN) {
|
|
190
188
|
envVarValue = envVarValue.length > 1 ? "true" : "false";
|
|
191
189
|
}
|
|
192
|
-
envVarValues[positional.name][index] =
|
|
193
|
-
envVarValue;
|
|
190
|
+
envVarValues[positional.name][index] = envVarValue;
|
|
194
191
|
}
|
|
195
192
|
});
|
|
196
193
|
}
|
|
@@ -200,7 +197,7 @@ export function getSubCommandValuesFromEnvVars(cliConfig, command) {
|
|
|
200
197
|
if (value === undefined) {
|
|
201
198
|
return undefined;
|
|
202
199
|
}
|
|
203
|
-
if (positional.type ===
|
|
200
|
+
if (positional.type === ValueTypeName.BOOLEAN) {
|
|
204
201
|
value = value.length > 1 ? "true" : "false";
|
|
205
202
|
}
|
|
206
203
|
// set primitive value
|
|
@@ -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;
|
|
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;AAMrF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CACxC;AAsDD,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,cAAc,EAC9B,qBAAqB,EAAE,qBAAqB,EAC5C,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC,CA2Cf;AA2BD,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,OAAO,EACvB,aAAa,EAAE,aAAa,GAC3B,SAAS,CA6DX;AAED,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CA+C3E;AAkLD,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,OAAO,EACvB,UAAU,EAAE,UAAU,EACtB,kBAAkB,EAAE,OAAO,GAC1B,KAAK,CAAC,WAAW,CAAC,CAoBpB;AACD,wBAAgB,8BAA8B,CAC5C,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,GACrB,KAAK,CAAC,WAAW,CAAC,CAgCpB;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,sBAAsB,EAAE,aAAa,CAAC,qBAAqB,CAAC,EAC5D,cAAc,EAAE,aAAa,CAAC,aAAa,CAAC,EAC5C,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,EAC1C,WAAW,EAAE,aAAa,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { distance } from "fastest-levenshtein";
|
|
2
|
-
import {
|
|
2
|
+
import { ValueTypeName, ComplexValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
import { getGlobalCommandArgumentConfigurationKey, getSubCommandArgumentConfigurationKey, } from "./configHelper.js";
|
|
4
4
|
const SYNTAX_INDENT_WIDTH = 2;
|
|
5
5
|
const MINIMUM_SYNTAX_COLUMN_WIDTH = 15;
|
|
@@ -74,21 +74,20 @@ export async function printHelpSections(printerService, tableGeneratorService, s
|
|
|
74
74
|
function getGlobalCommandArgumentForm(globalCommandArgument) {
|
|
75
75
|
let argumentSyntax = "";
|
|
76
76
|
switch (globalCommandArgument.type) {
|
|
77
|
-
case
|
|
77
|
+
case ValueTypeName.BOOLEAN:
|
|
78
78
|
argumentSyntax = "true|false";
|
|
79
79
|
break;
|
|
80
|
-
case
|
|
80
|
+
case ValueTypeName.INTEGER:
|
|
81
81
|
argumentSyntax = "<integer_value>";
|
|
82
82
|
break;
|
|
83
|
-
case
|
|
83
|
+
case ValueTypeName.NUMBER:
|
|
84
84
|
argumentSyntax = "<number_value>";
|
|
85
85
|
break;
|
|
86
|
-
case
|
|
86
|
+
case ValueTypeName.STRING:
|
|
87
87
|
argumentSyntax = "<string_value>";
|
|
88
88
|
break;
|
|
89
89
|
}
|
|
90
|
-
if (globalCommandArgument.isOptional ||
|
|
91
|
-
globalCommandArgument.type === ArgumentValueTypeName.BOOLEAN) {
|
|
90
|
+
if (globalCommandArgument.isOptional || globalCommandArgument.type === ValueTypeName.BOOLEAN) {
|
|
92
91
|
argumentSyntax = `[${argumentSyntax}]`;
|
|
93
92
|
}
|
|
94
93
|
return argumentSyntax;
|
|
@@ -106,13 +105,13 @@ export function getGlobalArgumentHelpEntry(cliConfig, includeEnvVars, globalComm
|
|
|
106
105
|
}
|
|
107
106
|
else {
|
|
108
107
|
switch (argument.type) {
|
|
109
|
-
case
|
|
108
|
+
case ValueTypeName.STRING:
|
|
110
109
|
notesItems.push("string value");
|
|
111
110
|
break;
|
|
112
|
-
case
|
|
111
|
+
case ValueTypeName.INTEGER:
|
|
113
112
|
notesItems.push("integer value");
|
|
114
113
|
break;
|
|
115
|
-
case
|
|
114
|
+
case ValueTypeName.NUMBER:
|
|
116
115
|
notesItems.push("number value");
|
|
117
116
|
break;
|
|
118
117
|
}
|
|
@@ -151,16 +150,16 @@ export function getSubCommandArgumentsSyntax(subCommand) {
|
|
|
151
150
|
subCommand.options.forEach((option) => {
|
|
152
151
|
let optionSyntax = `--${option.name}`;
|
|
153
152
|
switch (option.type) {
|
|
154
|
-
case
|
|
153
|
+
case ValueTypeName.BOOLEAN:
|
|
155
154
|
optionSyntax = `${optionSyntax} [true|false]`;
|
|
156
155
|
break;
|
|
157
|
-
case
|
|
156
|
+
case ValueTypeName.INTEGER:
|
|
158
157
|
optionSyntax = `${optionSyntax} <integer_value>`;
|
|
159
158
|
break;
|
|
160
|
-
case
|
|
159
|
+
case ValueTypeName.NUMBER:
|
|
161
160
|
optionSyntax = `${optionSyntax} <number_value>`;
|
|
162
161
|
break;
|
|
163
|
-
case
|
|
162
|
+
case ValueTypeName.STRING:
|
|
164
163
|
optionSyntax = `${optionSyntax} <string_value>`;
|
|
165
164
|
break;
|
|
166
165
|
case ComplexValueTypeName.COMPLEX:
|
|
@@ -219,16 +218,16 @@ function getOptionHelpEntry(cliConfig, includeEnvVars, command, option, subEntry
|
|
|
219
218
|
}
|
|
220
219
|
else {
|
|
221
220
|
switch (option.type) {
|
|
222
|
-
case
|
|
221
|
+
case ValueTypeName.STRING:
|
|
223
222
|
notesItems.push(`string value`);
|
|
224
223
|
break;
|
|
225
|
-
case
|
|
224
|
+
case ValueTypeName.INTEGER:
|
|
226
225
|
notesItems.push(`integer value`);
|
|
227
226
|
break;
|
|
228
|
-
case
|
|
227
|
+
case ValueTypeName.NUMBER:
|
|
229
228
|
notesItems.push(`number value`);
|
|
230
229
|
break;
|
|
231
|
-
case
|
|
230
|
+
case ValueTypeName.BOOLEAN:
|
|
232
231
|
notesItems.push(`boolean value`);
|
|
233
232
|
break;
|
|
234
233
|
}
|
|
@@ -287,16 +286,16 @@ function getPositionalHelpEntry(cliConfig, includeEnvVars, command, positional)
|
|
|
287
286
|
}
|
|
288
287
|
else {
|
|
289
288
|
switch (positional.type) {
|
|
290
|
-
case
|
|
289
|
+
case ValueTypeName.STRING:
|
|
291
290
|
notesItems.push(`string value`);
|
|
292
291
|
break;
|
|
293
|
-
case
|
|
292
|
+
case ValueTypeName.INTEGER:
|
|
294
293
|
notesItems.push(`integer value`);
|
|
295
294
|
break;
|
|
296
|
-
case
|
|
295
|
+
case ValueTypeName.NUMBER:
|
|
297
296
|
notesItems.push(`number value`);
|
|
298
297
|
break;
|
|
299
|
-
case
|
|
298
|
+
case ValueTypeName.BOOLEAN:
|
|
300
299
|
notesItems.push(`boolean value`);
|
|
301
300
|
break;
|
|
302
301
|
}
|
|
@@ -401,7 +400,7 @@ export function getMultiCommandAppSyntax(context, globalModifierCommands, global
|
|
|
401
400
|
const optionArgMandatory = globalModifierCommands.every((modifier) => modifier.argument !== undefined &&
|
|
402
401
|
!modifier.argument.isOptional &&
|
|
403
402
|
modifier.argument.defaultValue === undefined &&
|
|
404
|
-
modifier.argument.type !==
|
|
403
|
+
modifier.argument.type !== ValueTypeName.BOOLEAN);
|
|
405
404
|
syntax += optionArgMandatory ? " <value>" : " [<value>]";
|
|
406
405
|
}
|
|
407
406
|
syntax += "]";
|
|
@@ -422,7 +421,7 @@ export function getMultiCommandAppSyntax(context, globalModifierCommands, global
|
|
|
422
421
|
((globalCommand.argument.isOptional !== undefined && globalCommand.argument.isOptional) ||
|
|
423
422
|
globalCommand.argument.defaultValue !== undefined));
|
|
424
423
|
argValueOptional = globalCommands.some((globalCommand) => globalCommand.argument !== undefined &&
|
|
425
|
-
globalCommand.argument.type ===
|
|
424
|
+
globalCommand.argument.type === ValueTypeName.BOOLEAN);
|
|
426
425
|
}
|
|
427
426
|
}
|
|
428
427
|
if (groupCommands.length > 0 || subCommands.length > 0) {
|
|
@@ -442,10 +441,10 @@ export function getMultiCommandAppSyntax(context, globalModifierCommands, global
|
|
|
442
441
|
subCommand.positionals.some((positional) => positional.isVarargOptional !== undefined && positional.isVarargOptional));
|
|
443
442
|
argValueOptional =
|
|
444
443
|
argValueOptional ||
|
|
445
|
-
groupCommands.some((groupCommand) => groupCommand.memberSubCommands.some((memberCommand) => memberCommand.options.some((option) => option.type ===
|
|
446
|
-
memberCommand.positionals.some((positional) => positional.type ===
|
|
447
|
-
subCommands.some((subCommand) => subCommand.options.some((option) => option.type ===
|
|
448
|
-
subCommand.positionals.some((positional) => positional.type ===
|
|
444
|
+
groupCommands.some((groupCommand) => groupCommand.memberSubCommands.some((memberCommand) => memberCommand.options.some((option) => option.type === ValueTypeName.BOOLEAN ||
|
|
445
|
+
memberCommand.positionals.some((positional) => positional.type === ValueTypeName.BOOLEAN)))) ||
|
|
446
|
+
subCommands.some((subCommand) => subCommand.options.some((option) => option.type === ValueTypeName.BOOLEAN) ||
|
|
447
|
+
subCommand.positionals.some((positional) => positional.type === ValueTypeName.BOOLEAN));
|
|
449
448
|
multipleArg =
|
|
450
449
|
multipleArg ||
|
|
451
450
|
groupCommands.some((groupCommand) => groupCommand.memberSubCommands.some((memberCommand) => memberCommand.options.some((option) => option.isArray) ||
|
package/index.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
// Argument API
|
|
2
2
|
export type { Argument } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
export type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from "@flowscripter/dynamic-cli-framework-api";
|
|
11
|
-
export {
|
|
12
|
-
ArgumentValueTypeName,
|
|
13
|
-
ComplexValueTypeName,
|
|
4
|
+
SingleValueType,
|
|
5
|
+
Values,
|
|
6
|
+
ValueType,
|
|
7
|
+
PopulatedSingleValueType,
|
|
8
|
+
PopulatedValues,
|
|
9
|
+
PopulatedValueType,
|
|
14
10
|
} from "@flowscripter/dynamic-cli-framework-api";
|
|
11
|
+
export { ValueTypeName, ComplexValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
15
12
|
export type { ComplexOption } from "@flowscripter/dynamic-cli-framework-api";
|
|
16
13
|
export { MAXIMUM_COMPLEX_OPTION_NESTING_DEPTH } from "@flowscripter/dynamic-cli-framework-api";
|
|
17
14
|
export type { SubCommandArgument } from "@flowscripter/dynamic-cli-framework-api";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/dynamic-cli-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"build": "tsc -p tsconfig.build.json"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@flowscripter/dynamic-cli-framework-api": "^1.4.
|
|
51
|
+
"@flowscripter/dynamic-cli-framework-api": "^1.4.1",
|
|
52
52
|
"@flowscripter/dynamic-plugin-framework": "1.12.0",
|
|
53
53
|
"emphasize": "^7.0.0",
|
|
54
54
|
"fastest-levenshtein": "^1.0.16",
|
|
@@ -4,9 +4,9 @@ import type { SubCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
|
4
4
|
import type { GlobalCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
5
|
import type { GroupCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
6
6
|
import {
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
|
|
7
|
+
type SingleValueType,
|
|
8
|
+
type Values,
|
|
9
|
+
ValueTypeName,
|
|
10
10
|
} from "@flowscripter/dynamic-cli-framework-api";
|
|
11
11
|
import type { Context } from "@flowscripter/dynamic-cli-framework-api";
|
|
12
12
|
import type { HelpSection } from "../util/helpHelper.ts";
|
|
@@ -308,11 +308,11 @@ export class MultiCommandCliHelpGlobalCommand
|
|
|
308
308
|
|
|
309
309
|
readonly argument = {
|
|
310
310
|
name: "command",
|
|
311
|
-
type:
|
|
311
|
+
type: ValueTypeName.STRING,
|
|
312
312
|
isOptional: true,
|
|
313
313
|
};
|
|
314
314
|
|
|
315
|
-
public async execute(context: Context, argumentValue?:
|
|
315
|
+
public async execute(context: Context, argumentValue?: SingleValueType): Promise<void> {
|
|
316
316
|
const commandName = argumentValue as string | undefined;
|
|
317
317
|
if (commandName !== undefined) {
|
|
318
318
|
await this.printUsageHelp(context, commandName);
|
|
@@ -334,13 +334,13 @@ export class MultiCommandCliHelpSubCommand
|
|
|
334
334
|
public readonly positionals: ReadonlyArray<Positional> = [
|
|
335
335
|
{
|
|
336
336
|
name: "command",
|
|
337
|
-
type:
|
|
337
|
+
type: ValueTypeName.STRING,
|
|
338
338
|
isVarargOptional: true,
|
|
339
339
|
description: "Display help for the specific <command>",
|
|
340
340
|
},
|
|
341
341
|
];
|
|
342
342
|
|
|
343
|
-
public async execute(context: Context, argumentValues:
|
|
343
|
+
public async execute(context: Context, argumentValues: Values): Promise<void> {
|
|
344
344
|
const commandName = argumentValues["command"] as string | undefined;
|
|
345
345
|
if (commandName !== undefined) {
|
|
346
346
|
await this.printUsageHelp(context, commandName);
|
|
@@ -4,11 +4,8 @@ import type { GlobalCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
|
4
4
|
import type { Argument } from "@flowscripter/dynamic-cli-framework-api";
|
|
5
5
|
import type { GroupCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
6
6
|
import type { SubCommand } from "@flowscripter/dynamic-cli-framework-api";
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
9
|
-
ArgumentValueTypeName,
|
|
10
|
-
ComplexValueTypeName,
|
|
11
|
-
} from "@flowscripter/dynamic-cli-framework-api";
|
|
7
|
+
import type { SingleValueType } from "@flowscripter/dynamic-cli-framework-api";
|
|
8
|
+
import { ValueTypeName, ComplexValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
12
9
|
import type { Option } from "@flowscripter/dynamic-cli-framework-api";
|
|
13
10
|
import type { ComplexOption } from "@flowscripter/dynamic-cli-framework-api";
|
|
14
11
|
import { isComplexOption } from "../argument/ArgumentTypeGuards.ts";
|
|
@@ -30,14 +27,14 @@ import type { GlobalCommandArgument } from "@flowscripter/dynamic-cli-framework-
|
|
|
30
27
|
const logger = getLogger("commandValidation");
|
|
31
28
|
|
|
32
29
|
function validateValueType(
|
|
33
|
-
type:
|
|
34
|
-
value:
|
|
30
|
+
type: ValueTypeName,
|
|
31
|
+
value: SingleValueType,
|
|
35
32
|
argumentName: string,
|
|
36
33
|
isDefaultValue: boolean,
|
|
37
34
|
isRangeValue: boolean,
|
|
38
35
|
): void {
|
|
39
36
|
switch (type) {
|
|
40
|
-
case
|
|
37
|
+
case ValueTypeName.BOOLEAN:
|
|
41
38
|
if (typeof value !== "boolean") {
|
|
42
39
|
throw new Error(
|
|
43
40
|
`Specified ${
|
|
@@ -46,7 +43,7 @@ function validateValueType(
|
|
|
46
43
|
);
|
|
47
44
|
}
|
|
48
45
|
break;
|
|
49
|
-
case
|
|
46
|
+
case ValueTypeName.NUMBER:
|
|
50
47
|
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
51
48
|
throw new Error(
|
|
52
49
|
`Specified ${
|
|
@@ -55,7 +52,7 @@ function validateValueType(
|
|
|
55
52
|
);
|
|
56
53
|
}
|
|
57
54
|
break;
|
|
58
|
-
case
|
|
55
|
+
case ValueTypeName.INTEGER:
|
|
59
56
|
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
60
57
|
throw new Error(
|
|
61
58
|
`Specified ${
|
|
@@ -64,7 +61,7 @@ function validateValueType(
|
|
|
64
61
|
);
|
|
65
62
|
}
|
|
66
63
|
break;
|
|
67
|
-
case
|
|
64
|
+
case ValueTypeName.STRING:
|
|
68
65
|
if (typeof value !== "string") {
|
|
69
66
|
throw new Error(
|
|
70
67
|
`Specified ${
|
|
@@ -102,15 +99,15 @@ function isConfigurationKeyLegal(configurationKey: string): boolean {
|
|
|
102
99
|
|
|
103
100
|
function validateArgument(argument: Argument, name: string): void {
|
|
104
101
|
if (
|
|
105
|
-
argument.type !==
|
|
106
|
-
argument.type !==
|
|
107
|
-
argument.type !==
|
|
108
|
-
argument.type !==
|
|
102
|
+
argument.type !== ValueTypeName.NUMBER &&
|
|
103
|
+
argument.type !== ValueTypeName.INTEGER &&
|
|
104
|
+
argument.type !== ValueTypeName.STRING &&
|
|
105
|
+
argument.type !== ValueTypeName.BOOLEAN
|
|
109
106
|
) {
|
|
110
107
|
throw new Error(`Illegal type: '${argument.type}' for argument: '${name}'`);
|
|
111
108
|
}
|
|
112
109
|
if (argument.allowableValues) {
|
|
113
|
-
if (argument.type ===
|
|
110
|
+
if (argument.type === ValueTypeName.BOOLEAN) {
|
|
114
111
|
throw new Error(
|
|
115
112
|
`Illegal type: '${argument.type}' for argument: '${name}' with allowable values specified`,
|
|
116
113
|
);
|
|
@@ -120,21 +117,18 @@ function validateArgument(argument: Argument, name: string): void {
|
|
|
120
117
|
});
|
|
121
118
|
}
|
|
122
119
|
if (argument.isCaseInsensitive !== undefined) {
|
|
123
|
-
if (argument.type ===
|
|
120
|
+
if (argument.type === ValueTypeName.BOOLEAN && argument.isCaseInsensitive === false) {
|
|
124
121
|
throw new Error(
|
|
125
122
|
`Illegal type: '${argument.type}' for argument: '${name}' must always be case insensitive`,
|
|
126
123
|
);
|
|
127
|
-
} else if (argument.type !==
|
|
124
|
+
} else if (argument.type !== ValueTypeName.STRING) {
|
|
128
125
|
throw new Error(
|
|
129
126
|
`Illegal type: '${argument.type}' for argument: '${name}' with case insensitive specified`,
|
|
130
127
|
);
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
130
|
if (argument.minValueInclusive !== undefined) {
|
|
134
|
-
if (
|
|
135
|
-
argument.type !== ArgumentValueTypeName.NUMBER &&
|
|
136
|
-
argument.type !== ArgumentValueTypeName.INTEGER
|
|
137
|
-
) {
|
|
131
|
+
if (argument.type !== ValueTypeName.NUMBER && argument.type !== ValueTypeName.INTEGER) {
|
|
138
132
|
throw new Error(
|
|
139
133
|
`Illegal type: '${argument.type}' for argument: '${name}' with min value specified`,
|
|
140
134
|
);
|
|
@@ -147,10 +141,7 @@ function validateArgument(argument: Argument, name: string): void {
|
|
|
147
141
|
validateValueType(argument.type, argument.minValueInclusive, name, false, true);
|
|
148
142
|
}
|
|
149
143
|
if (argument.maxValueInclusive !== undefined) {
|
|
150
|
-
if (
|
|
151
|
-
argument.type !== ArgumentValueTypeName.NUMBER &&
|
|
152
|
-
argument.type !== ArgumentValueTypeName.INTEGER
|
|
153
|
-
) {
|
|
144
|
+
if (argument.type !== ValueTypeName.NUMBER && argument.type !== ValueTypeName.INTEGER) {
|
|
154
145
|
throw new Error(
|
|
155
146
|
`Illegal type: '${argument.type}' for argument: '${name}' with max value specified`,
|
|
156
147
|
);
|
package/src/runtime/parser.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
ValueType,
|
|
3
|
+
PopulatedSingleValueType,
|
|
4
|
+
PopulatedValues,
|
|
5
5
|
} from "@flowscripter/dynamic-cli-framework-api";
|
|
6
6
|
import type { InvalidArgument } from "@flowscripter/dynamic-cli-framework-api";
|
|
7
7
|
import type { ParseResult } from "@flowscripter/dynamic-cli-framework-api";
|
|
@@ -25,11 +25,11 @@ export type { ParseResult } from "@flowscripter/dynamic-cli-framework-api";
|
|
|
25
25
|
* Parse the arguments for the specified {@link CommandClause} assuming it contains a {@link SubCommand}.
|
|
26
26
|
*
|
|
27
27
|
* @param commandClause the clause to parse.
|
|
28
|
-
* @param defaultValues optional default {@link
|
|
28
|
+
* @param defaultValues optional default {@link PopulatedValues} to use for population before parsing the provided arguments.
|
|
29
29
|
*/
|
|
30
30
|
export function parseSubCommandClause(
|
|
31
31
|
commandClause: CommandClause,
|
|
32
|
-
defaultValues?:
|
|
32
|
+
defaultValues?: PopulatedValues,
|
|
33
33
|
): ParseResult {
|
|
34
34
|
const command = commandClause.command as SubCommand;
|
|
35
35
|
const potentialArgs = commandClause.potentialArgs;
|
|
@@ -82,7 +82,7 @@ export function parseSubCommandClause(
|
|
|
82
82
|
command.positionals.forEach((positional) => {
|
|
83
83
|
const validatedValue = validatePositionalValue(
|
|
84
84
|
positional,
|
|
85
|
-
populatedArgumentValues[positional.name] as
|
|
85
|
+
populatedArgumentValues[positional.name] as ValueType,
|
|
86
86
|
invalidArguments,
|
|
87
87
|
);
|
|
88
88
|
if (validatedValue !== undefined) {
|
|
@@ -117,11 +117,11 @@ export function parseSubCommandClause(
|
|
|
117
117
|
* Parse the arguments for the specified {@link CommandClause} assuming it contains a {@link GlobalCommand} or {@link GlobalModifierCommand}.
|
|
118
118
|
*
|
|
119
119
|
* @param commandClause the clause to parse.
|
|
120
|
-
* @param defaultValue optional default {@link
|
|
120
|
+
* @param defaultValue optional default {@link PopulatedSingleValueType} to use for population before parsing the provided arguments.
|
|
121
121
|
*/
|
|
122
122
|
export function parseGlobalCommandClause(
|
|
123
123
|
commandClause: CommandClause,
|
|
124
|
-
defaultValue?:
|
|
124
|
+
defaultValue?: PopulatedSingleValueType,
|
|
125
125
|
): ParseResult {
|
|
126
126
|
const command = commandClause.command as GlobalCommand;
|
|
127
127
|
const potentialArgs = commandClause.potentialArgs;
|