diff --git a/src/main/ts/cli.ts b/src/main/ts/cli.ts index af30a49..8f9390b 100644 --- a/src/main/ts/cli.ts +++ b/src/main/ts/cli.ts @@ -6,6 +6,18 @@ import { Command, Option } from 'commander' import { run } from './runner' +const parseMultipleValueArg = ( + value: string, + previous: string | string[] | undefined, +) => { + if (!previous) { + return value + } + + const previousArray = Array.isArray(previous) ? previous : [previous] + return previousArray.concat([value]) +} + const env = process.env const flags = new Command() .addOption( diff --git a/src/main/ts/util.ts b/src/main/ts/util.ts index 03f6c1b..e57eb7c 100644 --- a/src/main/ts/util.ts +++ b/src/main/ts/util.ts @@ -71,10 +71,16 @@ export const formatFlags = (flags: TFlags, ...picklist: string[]): string[] => const flag = formatFlag(key) if (checkValue(key, value, omitlist, picklist)) { - memo.push(flag) + if (!Array.isArray(value)) { + memo.push(flag) - if (value !== true) { - memo.push(value) + if (value !== true) { + memo.push(String(value)) + } + } else { + value.forEach((val) => { + memo.push(flag, String(val)) + }) } }