| 37 | } |
| 38 | |
| 39 | function parseOptions(argv) { |
| 40 | const positional = []; |
| 41 | const options = { |
| 42 | format: "json", |
| 43 | output: null, |
| 44 | metricPackManifests: [], |
| 45 | observedUsagePaths: [], |
| 46 | configPath: null, |
| 47 | usageOutPath: null, |
| 48 | resultOutPath: null, |
| 49 | model: null, |
| 50 | goal: null, |
| 51 | request: null, |
| 52 | dryRun: false, |
| 53 | briefOut: null, |
| 54 | }; |
| 55 | |
| 56 | for (let index = 0; index < argv.length; index += 1) { |
| 57 | const arg = argv[index]; |
| 58 | if (arg === "--format") { |
| 59 | options.format = argv[index + 1]; |
| 60 | index += 1; |
| 61 | } else if (arg === "--output") { |
| 62 | options.output = argv[index + 1]; |
| 63 | index += 1; |
| 64 | } else if (arg === "--metric-pack") { |
| 65 | options.metricPackManifests.push(argv[index + 1]); |
| 66 | index += 1; |
| 67 | } else if (arg === "--observed-usage") { |
| 68 | options.observedUsagePaths.push(argv[index + 1]); |
| 69 | index += 1; |
| 70 | } else if (arg === "--config") { |
| 71 | options.configPath = argv[index + 1]; |
| 72 | index += 1; |
| 73 | } else if (arg === "--usage-out") { |
| 74 | options.usageOutPath = argv[index + 1]; |
| 75 | index += 1; |
| 76 | } else if (arg === "--result-out") { |
| 77 | options.resultOutPath = argv[index + 1]; |
| 78 | index += 1; |
| 79 | } else if (arg === "--model") { |
| 80 | options.model = argv[index + 1]; |
| 81 | index += 1; |
| 82 | } else if (arg === "--goal") { |
| 83 | options.goal = argv[index + 1]; |
| 84 | index += 1; |
| 85 | } else if (arg === "--request") { |
| 86 | options.request = argv[index + 1]; |
| 87 | index += 1; |
| 88 | } else if (arg === "--dry-run") { |
| 89 | options.dryRun = true; |
| 90 | } else if (arg === "--brief-out") { |
| 91 | options.briefOut = argv[index + 1]; |
| 92 | index += 1; |
| 93 | } else if (arg === "--help" || arg === "-h") { |
| 94 | options.help = true; |
| 95 | } else { |
| 96 | positional.push(arg); |