| 59 | } |
| 60 | |
| 61 | function parseArgs(argv: string[]): { |
| 62 | sessionPrefix: string; |
| 63 | dir: string; |
| 64 | since?: string; |
| 65 | until?: string; |
| 66 | limit?: number; |
| 67 | showDiff: boolean; |
| 68 | allBusts: boolean; |
| 69 | allRows: boolean; |
| 70 | } { |
| 71 | const args = argv.slice(2); |
| 72 | const sessionPrefix = args.find((a) => !a.startsWith("--")) ?? ""; |
| 73 | const getOpt = (name: string): string | undefined => { |
| 74 | const i = args.indexOf(name); |
| 75 | return i >= 0 && i + 1 < args.length ? args[i + 1] : undefined; |
| 76 | }; |
| 77 | const dir = |
| 78 | getOpt("--dir") ?? join(tmpdir(), "opencode-anthropic-auth-dumps"); |
| 79 | const limitRaw = getOpt("--limit"); |
| 80 | return { |
| 81 | sessionPrefix, |
| 82 | dir, |
| 83 | since: getOpt("--since"), |
| 84 | until: getOpt("--until"), |
| 85 | limit: limitRaw ? Number.parseInt(limitRaw, 10) : undefined, |
| 86 | showDiff: args.includes("--show-diff"), |
| 87 | allBusts: args.includes("--all-busts"), |
| 88 | allRows: args.includes("--all-rows"), |
| 89 | }; |
| 90 | } |
| 91 | |
| 92 | /** Recursively strip `cache_control` fields — marker movement is not content. */ |
| 93 | function stripCacheControl(value: unknown): unknown { |