UNPKG

@cloud-copilot/cli

Version:

A standardized library for CLI building TypeScript CLI applications

39 lines 1.5 kB
export function enumArrayArgument(options) { return { description: options.description + `. One or more values required, valid values are: ${options.validValues.join(', ')}`, validateValues: async (currentValue, values) => { if (values.length == 0) { return { valid: false, message: 'At least one value is required' }; } const invalidValues = []; const validValues = []; for (const value of values) { const match = options.validValues.find((v) => v.toLowerCase() === value.toLowerCase()); if (!match) { invalidValues.push(value); } else { validValues.push(match); } } if (invalidValues.length > 0) { return { valid: false, message: `${invalidValues.map((v) => `${v}`).join(', ')} is not one of the allowed values: ${options.validValues.join(', ')}` }; } return { valid: true, value: validValues }; }, reduceValues: async (current, newValues) => { if (!current) { return newValues; } current.push(...newValues); return current; }, defaultValue: options.defaultValue, acceptMultipleValues: () => true }; } //# sourceMappingURL=enumArrayArgument.js.map