Function
readOption
(args: ReadonlyArray<string>, name: string)
Source from the content-addressed store, hash-verified
| 56 | }; |
| 57 | |
| 58 | const readOption = (args: ReadonlyArray<string>, name: string): string | undefined => { |
| 59 | const index = args.indexOf(name); |
| 60 | if (index === -1) return undefined; |
| 61 | const value = args[index + 1]; |
| 62 | if (!value || value.startsWith("--")) { |
| 63 | throw new Error(`Missing value for ${name}`); |
| 64 | } |
| 65 | return value; |
| 66 | }; |
| 67 | |
| 68 | if (import.meta.main) { |
| 69 | run(); |
Tested by
no test coverage detected