(argv)
| 14 | } |
| 15 | |
| 16 | function parseArgs(argv) { |
| 17 | const args = argv.slice(2); |
| 18 | const parsed = { |
| 19 | targets: [], |
| 20 | dryRun: false, |
| 21 | json: false, |
| 22 | help: false, |
| 23 | }; |
| 24 | |
| 25 | for (let index = 0; index < args.length; index += 1) { |
| 26 | const arg = args[index]; |
| 27 | |
| 28 | if (arg === '--target') { |
| 29 | parsed.targets.push(args[index + 1] || null); |
| 30 | index += 1; |
| 31 | } else if (arg === '--dry-run') { |
| 32 | parsed.dryRun = true; |
| 33 | } else if (arg === '--json') { |
| 34 | parsed.json = true; |
| 35 | } else if (arg === '--help' || arg === '-h') { |
| 36 | parsed.help = true; |
| 37 | } else { |
| 38 | throw new Error(`Unknown argument: ${arg}`); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | return parsed; |
| 43 | } |
| 44 | |
| 45 | function printHuman(result) { |
| 46 | if (result.results.length === 0) { |
no outgoing calls