diff --git a/CHANGELOG.md b/CHANGELOG.md index d78bba5..e9cb818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project are documented here, following [Keep a Changelog](https://keepachangelog.com/) and semantic versioning. +## [0.1.9] - 2026-09-12 + +### Fixed + +- Reject unknown CLI flags (for example `--wriet`) with exit code 2 instead of + silently ignoring them and running report-only. + ## [0.1.8] - 2026-09-12 ### Added diff --git a/package-lock.json b/package-lock.json index e241c19..15863cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ctxtrim", - "version": "0.1.8", + "version": "0.1.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ctxtrim", - "version": "0.1.8", + "version": "0.1.9", "license": "MIT", "bin": { "ctxtrim": "bin/ctxtrim.js" diff --git a/package.json b/package.json index b7ec74a..3f9e1ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ctxtrim", - "version": "0.1.8", + "version": "0.1.9", "description": "Trim what bloats your AI coding context. Scan a repo, find the high-cost/low-value files ballooning your Claude Code / Cursor / Codex context, and write ignore files to cut token cost. Zero dependencies.", "type": "module", "bin": { diff --git a/src/cli.js b/src/cli.js index c961521..90eb5e6 100644 --- a/src/cli.js +++ b/src/cli.js @@ -47,6 +47,7 @@ function parse(argv) { else if (has("--top")) o.top = Number(val()); else if (has("--format")) o.format = val(); else if (has("--fail-on-waste")) o.failOnWaste = Number(val()); + else if (a.startsWith("-")) return { ...o, error: `ctxtrim: unknown option: ${a}\n` }; else if (!a.startsWith("-")) { if (o.path !== null) return { ...o, error: "ctxtrim: only one path may be supplied\n" }; o.path = a; diff --git a/test/ctxtrim.test.js b/test/ctxtrim.test.js index 08c11fc..da50d9f 100644 --- a/test/ctxtrim.test.js +++ b/test/ctxtrim.test.js @@ -190,6 +190,12 @@ test("CLI fails only when waste reaches the threshold", () => { assert.equal(pass.status, 0, `clean repo should pass a 50%% threshold\n${pass.stderr}`); }); +test("CLI rejects unknown flags", () => { + const result = spawnSync(process.execPath, [cli, repo, "--wriet"], { encoding: "utf8" }); + assert.equal(result.status, 2, `--wriet should fail with exit 2\n${result.stderr}`); + assert.match(result.stderr, /ctxtrim: unknown (option|flag).*--wriet/i); +}); + test("CLI rejects non-finite and negative numeric options", () => { const invalid = [ ["--max-tokens", "abc"],