| 446 | |
| 447 | // Helper: split custom CLI flags honoring simple quotes |
| 448 | const splitArgs = (input: string): string[] => { |
| 449 | const args: string[] = []; |
| 450 | let current = ''; |
| 451 | let quote: '"' | "'" | null = null; |
| 452 | let escape = false; |
| 453 | for (const ch of input) { |
| 454 | if (escape) { |
| 455 | current += ch; |
| 456 | escape = false; |
| 457 | continue; |
| 458 | } |
| 459 | if (ch === '\\') { |
| 460 | escape = true; |
| 461 | continue; |
| 462 | } |
| 463 | if (quote) { |
| 464 | if (ch === quote) { |
| 465 | quote = null; |
| 466 | } else { |
| 467 | current += ch; |
| 468 | } |
| 469 | continue; |
| 470 | } |
| 471 | if (ch === '"' || ch === "'") { |
| 472 | quote = ch as '"' | "'"; |
| 473 | continue; |
| 474 | } |
| 475 | if (/\s/.test(ch)) { |
| 476 | if (current.length > 0) { |
| 477 | args.push(current); |
| 478 | current = ''; |
| 479 | } |
| 480 | continue; |
| 481 | } |
| 482 | current += ch; |
| 483 | } |
| 484 | if (current.length > 0) args.push(current); |
| 485 | return args; |
| 486 | }; |
| 487 | const parsedRegions = parsedInputs.regions |
| 488 | .split(',') |
| 489 | .map((region) => region.trim()) |