(argv: string[])
| 84 | } |
| 85 | |
| 86 | function parseProjectCommand(argv: string[]): RuntimeHostCliCommand { |
| 87 | const action = argv[0]; |
| 88 | if (action !== 'list' && action !== 'add') { |
| 89 | return error( |
| 90 | action |
| 91 | ? `Unexpected runtime-host project command: ${action}` |
| 92 | : 'runtime-host project requires the list or add command', |
| 93 | ); |
| 94 | } |
| 95 | let rootPath: string | undefined; |
| 96 | let path: string | undefined; |
| 97 | for (let index = 1; index < argv.length; index += 1) { |
| 98 | const argument = argv[index]; |
| 99 | if (argument === '--root') { |
| 100 | const parsed = optionValue(argv, index, argument); |
| 101 | if (typeof parsed !== 'string') return parsed; |
| 102 | rootPath = parsed; |
| 103 | index += 1; |
| 104 | continue; |
| 105 | } |
| 106 | if (action === 'add' && path === undefined) { |
| 107 | path = argument; |
| 108 | continue; |
| 109 | } |
| 110 | return error(`Unexpected argument: ${argument ?? ''}`); |
| 111 | } |
| 112 | if (action === 'list') { |
| 113 | return { kind: 'runtime-host-project-list', ...(rootPath ? { rootPath } : {}) }; |
| 114 | } |
| 115 | if (!path) return error('runtime-host project add requires a path'); |
| 116 | return { kind: 'runtime-host-project-add', path, ...(rootPath ? { rootPath } : {}) }; |
| 117 | } |
| 118 | |
| 119 | function parseProfileCommand(argv: string[]): RuntimeHostCliCommand { |
| 120 | const action = argv[0]; |
no test coverage detected