| 3 | import { monotonicFactory } from "./ulid.js"; |
| 4 | |
| 5 | function parseArgs(args: Array<string>): Record<string, string | boolean> { |
| 6 | const output = {}; |
| 7 | |
| 8 | while (args.length > 0) { |
| 9 | const arg = args.shift(); |
| 10 | |
| 11 | if (/^\-\-/.test(arg)) { |
| 12 | if (/=/.test(arg)) { |
| 13 | const [key, value] = arg.split("="); |
| 14 | output[key.substring(2)] = value; |
| 15 | } else { |
| 16 | const value = args.shift(); |
| 17 | |
| 18 | if (/^-/.test(value)) { |
| 19 | args.unshift(value); |
| 20 | } else if (!value) { |
| 21 | output[arg.substring(2)] = true; |
| 22 | } else { |
| 23 | output[arg.substring(2)] = value; |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | return output; |
| 30 | } |
| 31 | |
| 32 | const argv = parseArgs(process.argv.slice(2)); |
| 33 | |