(values: readonly string[])
| 124 | } |
| 125 | |
| 126 | function parseKeyValueArgs(values: readonly string[]): Record<string, unknown> { |
| 127 | const result: Record<string, unknown> = {}; |
| 128 | for (const value of values) { |
| 129 | const eqIndex = value.indexOf("="); |
| 130 | if (eqIndex <= 0) { |
| 131 | throw new Error(`Invalid --arg "${value}". Expected key=value`); |
| 132 | } |
| 133 | const key = value.slice(0, eqIndex).trim(); |
| 134 | assert(key.length > 0, "Workflow --arg key must be non-empty"); |
| 135 | result[key] = parseScalar(value.slice(eqIndex + 1).trim()); |
| 136 | } |
| 137 | return result; |
| 138 | } |
| 139 | |
| 140 | function parseScalar(value: string): unknown { |
| 141 | if (value === "true") return true; |
no test coverage detected