(argv: readonly string[])
| 118 | } |
| 119 | |
| 120 | function parseArguments(argv: readonly string[]): CliOptions { |
| 121 | const options: CliOptions = { files: [], framework: 'preserve', write: false, help: false }; |
| 122 | for (let index = 0; index < argv.length; index++) { |
| 123 | const argument = argv[index]; |
| 124 | if (!argument) continue; |
| 125 | switch (argument) { |
| 126 | case '--source-root': |
| 127 | options.sourceRoot = requiredValue(argv, ++index, argument); |
| 128 | break; |
| 129 | case '--out-dir': |
| 130 | options.outputRoot = requiredValue(argv, ++index, argument); |
| 131 | break; |
| 132 | case '--source-repo': |
| 133 | options.repository = requiredValue(argv, ++index, argument); |
| 134 | break; |
| 135 | case '--source-sha': |
| 136 | options.sha = requiredValue(argv, ++index, argument); |
| 137 | break; |
| 138 | case '--mode': { |
| 139 | const mode = requiredValue(argv, ++index, argument); |
| 140 | if (mode !== 'cold' && mode !== 'platform') throw new Error(`Unknown mode: ${mode}`); |
| 141 | options.mode = mode; |
| 142 | break; |
| 143 | } |
| 144 | case '--framework': { |
| 145 | const framework = requiredValue(argv, ++index, argument); |
| 146 | if (framework !== 'preserve' && framework !== 'mocha-chai-vitest') throw new Error(`Unknown framework: ${framework}`); |
| 147 | options.framework = framework; |
| 148 | break; |
| 149 | } |
| 150 | case '--write': |
| 151 | options.write = true; |
| 152 | break; |
| 153 | case '--help': |
| 154 | case '-h': |
| 155 | options.help = true; |
| 156 | break; |
| 157 | default: |
| 158 | if (argument.startsWith('-')) throw new Error(`Unknown option: ${argument}`); |
| 159 | options.files.push(argument); |
| 160 | } |
| 161 | } |
| 162 | return options; |
| 163 | } |
| 164 | |
| 165 | function validateArguments(options: CliOptions): asserts options is RunnableCliOptions { |
| 166 | const missing = [ |
no test coverage detected