diff --git a/tasks/types.ts b/tasks/types.ts index 4074f1f13..f309530f5 100644 --- a/tasks/types.ts +++ b/tasks/types.ts @@ -75,9 +75,9 @@ const booleanArray: CLIArgumentType> = { }, }; -const stratConfig: CLIArgumentType = { +const stratConfig: CLIArgumentType = { name: "StratConfig", - parse: (_, strValue) => allStrategyConfigs[strValue] || {error: strValue}, + parse: (argName, strValue) => string.parse(argName, strValue), /** * Check if argument value is of type "StratConfig" * @@ -87,10 +87,13 @@ const stratConfig: CLIArgumentType = { * @throws HH301 if value is not of type "StratConfig" */ validate: (argName: string, argValue: any): void => { - if (!argValue || typeof argValue !== "object" || "error" in argValue) { - const invalidValue = "error" in argValue ? argValue.error : argValue; + string.validate(argName, argValue); + + const possibleValues = Object.keys(allStrategyConfigs); + + if (!possibleValues.includes(argValue)) { throw new Error( - `Invalid value '${invalidValue}' for argument '${argName}' of type \`StratConfig\`` + `Invalid value '${argValue}' for argument '${argName}', possible values: ${possibleValues}` ); } },