|
| 1 | +#!/usr/bin/env bun |
| 2 | +/** |
| 3 | + * CLI entry point for the RecordStream TUI pipeline builder. |
| 4 | + * |
| 5 | + * Usage: |
| 6 | + * recs tui [inputfile] Open TUI with optional input file |
| 7 | + * recs tui --session <id> Resume a saved session |
| 8 | + * recs tui --list List saved sessions |
| 9 | + * recs tui --clean Remove sessions older than 7 days |
| 10 | + * recs tui --pipeline "..." Start with an initial pipeline command |
| 11 | + */ |
| 12 | + |
| 13 | +import { launchTui, type TuiOptions } from "../src/tui/index.tsx"; |
| 14 | + |
| 15 | +const args = process.argv.slice(2); |
| 16 | + |
| 17 | +// Handle --list |
| 18 | +if (args.includes("--list")) { |
| 19 | + // TODO: implement session listing (Phase 3) |
| 20 | + console.log("No saved sessions. (Session persistence coming in Phase 3)"); |
| 21 | + process.exit(0); |
| 22 | +} |
| 23 | + |
| 24 | +// Handle --clean |
| 25 | +if (args.includes("--clean")) { |
| 26 | + // TODO: implement session cleanup (Phase 3) |
| 27 | + console.log("Session cleanup not yet implemented. (Phase 3)"); |
| 28 | + process.exit(0); |
| 29 | +} |
| 30 | + |
| 31 | +// Parse options |
| 32 | +const options: TuiOptions = {}; |
| 33 | + |
| 34 | +for (let i = 0; i < args.length; i++) { |
| 35 | + const arg = args[i]!; |
| 36 | + |
| 37 | + if (arg === "--session" || arg === "-s") { |
| 38 | + options.sessionId = args[i + 1]; |
| 39 | + i++; // skip value |
| 40 | + } else if (arg === "--pipeline" || arg === "-p") { |
| 41 | + options.pipeline = args[i + 1]; |
| 42 | + i++; // skip value |
| 43 | + } else if (arg === "--help" || arg === "-h") { |
| 44 | + console.log(`Usage: recs tui [options] [inputfile] |
| 45 | +
|
| 46 | +Options: |
| 47 | + --session, -s <id> Resume a saved session |
| 48 | + --pipeline, -p <cmd> Start with an initial pipeline command |
| 49 | + --list List saved sessions |
| 50 | + --clean Remove sessions older than 7 days |
| 51 | + --help, -h Show this help message |
| 52 | +
|
| 53 | +Examples: |
| 54 | + recs tui data.jsonl |
| 55 | + recs tui access.log --pipeline "fromre '^(\\S+)' | grep status=200" |
| 56 | + recs tui --session abc123 |
| 57 | + recs tui`); |
| 58 | + process.exit(0); |
| 59 | + } else if (!arg.startsWith("-")) { |
| 60 | + // Positional arg = input file |
| 61 | + options.inputFile = arg; |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +await launchTui(options); |
0 commit comments