Skip to content

Commit ac40b3a

Browse files
feat: add --output-dir for automatic timestamped report saving
Adds --output-dir <dir> to automatically save a JSON report with a timestamped filename (fm-bench_<timestamp>_<model>.json) to the given directory on every run. The directory is created if it does not exist. Pairs well with --compare for tracking performance over time. Co-authored-by: Cursor <cursor[bot]@users.noreply.github.com>
1 parent f22e251 commit ac40b3a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/cli.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ export async function runCli(argv = process.argv.slice(2)) {
9595
}
9696
}
9797

98+
if (parsed.outputDir) {
99+
const stamp = payload.startedAt.replace(/[:.]/g, '-').replace('T', '_').slice(0, 19);
100+
const firstModel = parsed.models?.flatMap((m) => String(m).split(',')).map((m) => m.trim()).filter(Boolean)[0] || 'all';
101+
const modelSlug = firstModel.replace(/[^a-z0-9]/gi, '_');
102+
const filename = `fm-bench_${stamp}_${modelSlug}.json`;
103+
const filePath = `${parsed.outputDir}/${filename}`;
104+
const written = await writeReport(filePath, payload, 'json');
105+
if (parsed.format !== 'json') {
106+
console.error(`Saved JSON report to ${written}`);
107+
}
108+
}
109+
98110
if (parsed.ci) {
99111
const ciResult = evaluateCi(payload);
100112
if (!ciResult.passed) {
@@ -309,6 +321,9 @@ export function parseArgs(argv) {
309321
case '--out':
310322
options.out = requireValue(arg, args);
311323
break;
324+
case '--output-dir':
325+
options.outputDir = requireValue(arg, args);
326+
break;
312327
case '--capture-output':
313328
options.captureOutput = true;
314329
break;
@@ -542,6 +557,7 @@ Output:
542557
--compact Force compact terminal layout
543558
--width <n> Render for a specific terminal width
544559
-o, --out <file> Save JSON or CSV report based on file extension
560+
--output-dir <dir> Save a timestamped JSON report to a directory automatically
545561
-v, --verbose Include per-run CSV after the summary table
546562
547563
Environment:

0 commit comments

Comments
 (0)