| 32 | }; |
| 33 | |
| 34 | function parseArgs(): Args { |
| 35 | const argv = process.argv.slice(2); |
| 36 | const out: Args = { |
| 37 | input: "apps/cursor/.seed/plugins.jsonl", |
| 38 | limit: Number.POSITIVE_INFINITY, |
| 39 | dryRun: false, |
| 40 | }; |
| 41 | for (let i = 0; i < argv.length; i++) { |
| 42 | const a = argv[i]; |
| 43 | if (a === "--input") out.input = argv[++i]; |
| 44 | else if (a === "--limit") out.limit = Number(argv[++i]); |
| 45 | else if (a === "--dry-run") out.dryRun = true; |
| 46 | else if (a === "--help" || a === "-h") { |
| 47 | console.log( |
| 48 | "Usage: insert-from-jsonl.ts [--input path] [--limit N] [--dry-run]", |
| 49 | ); |
| 50 | process.exit(0); |
| 51 | } else { |
| 52 | console.error(`Unknown arg: ${a}`); |
| 53 | process.exit(1); |
| 54 | } |
| 55 | } |
| 56 | return out; |
| 57 | } |
| 58 | |
| 59 | async function* readRows(path: string): AsyncGenerator<ExtractedRow> { |
| 60 | // Stream-like read by splitting the whole file by newlines. JSONL files at |