From 24314c9c95ffe820955b99f42b1254a8ac8d0545 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sun, 15 Mar 2026 16:14:47 -0700 Subject: [PATCH] Add -t/--filter flag for file path filtering --- CLAUDE.md | 1 + README.md | 1 + src/cli/index.ts | 18 ++++++++++++------ web/index.html | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f38af9c..f4d8c1c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,6 +12,7 @@ Transcript-based shell integration test runner. Bun + TypeScript. - `--clean-env` — start with empty environment - `--path ` — prepend to `$PATH` (repeatable) - `--timeout ` — per-command timeout (default `10s`) + - `-t, --filter ` — only run files whose path contains `` - `-v, --verbose` — print each command as it runs - `--port-from ` — auto-assign `$PORT` starting from n (default `5400`) - `--parallel` — run files in parallel diff --git a/README.md b/README.md index e49ef68..6ab7326 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Options: --clean-env Start with empty environment --path Prepend to PATH (repeatable) --timeout Per-command timeout (default: "10s") + -t, --filter Only run files matching (substring match) -v, --verbose Print each command as it runs --port-from Auto-assign $PORT starting from n (default: "5400") --parallel Run files in parallel diff --git a/src/cli/index.ts b/src/cli/index.ts index 5cf1080..4f00a6c 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -80,20 +80,26 @@ program .option("--timeout ", "Per-command timeout", "10s") .option("-v, --verbose", "Print each command as it runs") .option("--port-from ", "Auto-assign $PORT starting from ", "5400") + .option("-t, --filter ", "Only run files matching (substring match)") .option("--parallel", "Run files in parallel") .action(async (fileArgs: string[], opts) => { const timeoutMs = parseDuration(opts.timeout) const paths = fileArgs.length > 0 ? fileArgs : ["."] - const files = await findShoutFiles(paths) - - if (files.length === 0) { - console.error("No .shout files found") - process.exit(1) - } + let files = await findShoutFiles(paths) const start = performance.now() const results: TestResult[] = [] const cwd = process.cwd() + + if (opts.filter) { + const pattern = opts.filter + files = files.filter(f => relative(cwd, f).includes(pattern)) + } + + if (files.length === 0) { + console.error(opts.filter ? `No .shout files matching "${opts.filter}"` : "No .shout files found") + process.exit(1) + } const portFrom = parseInt(opts.portFrom, 10) if (Number.isNaN(portFrom)) { console.error("--port-from must be an integer") diff --git a/web/index.html b/web/index.html index 31a9124..8fa1ab2 100644 --- a/web/index.html +++ b/web/index.html @@ -248,6 +248,7 @@ Options: --clean-env Start with empty environment --path <path> Prepend <path> to PATH (repeatable) --timeout <dur> Per-command timeout (default: "10s") + -t, --filter Only run files matching <pattern> (substring match) -v, --verbose Print each command as it runs --port-from <n> Auto-assign $PORT starting from n (default: "5400") --parallel Run files in parallel