| 50 | } |
| 51 | |
| 52 | function parseArgs(argv) { |
| 53 | const options = { clients: CLIENTS, keep: false }; |
| 54 | for (const arg of argv) { |
| 55 | if (arg === '--keep') { |
| 56 | options.keep = true; |
| 57 | } else if (arg.startsWith('--clients=')) { |
| 58 | options.clients = arg.slice('--clients='.length).split(',').filter(Boolean); |
| 59 | const unknown = options.clients.filter(client => !CLIENTS.includes(client)); |
| 60 | if (unknown.length > 0) { |
| 61 | throw new Error(`Unknown client(s): ${unknown.join(', ')}`); |
| 62 | } |
| 63 | } else { |
| 64 | throw new Error(`Unknown argument: ${arg}`); |
| 65 | } |
| 66 | } |
| 67 | return options; |
| 68 | } |
| 69 | |
| 70 | class StepError extends Error {} |
| 71 | |