Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions __tests__/e2e/cli/cli-args.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ describe("policies: list (default)", () => {
expect(result.stdout).toContain("failproofai policies");
});

it("accepts --no-color after the subcommand", () => {
const result = runCli("policies", "--no-color");
assertSuccess(result);
expect(result.stdout).toContain("failproofai policies");
expect(result.stdout).not.toMatch(/\x1B\[/);
});

it("accepts --no-color before the subcommand", () => {
const result = runCli("--no-color", "policies");
assertSuccess(result);
expect(result.stdout).toContain("failproofai policies");
expect(result.stdout).not.toMatch(/\x1B\[/);
});

it("rejects unexpected positional argument", () => {
const result = runCli("policies", "hi");
assertCleanError(result, "Unexpected argument: hi");
Expand Down
13 changes: 12 additions & 1 deletion bin/failproofai.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* --hook <event> Hook event from Claude Code (minimal startup latency)
* --version / -v Print version and exit
* --help / -h Show usage and exit
* --no-color Suppress ANSI color output
* policies Manage policies (list / install / uninstall)
* (default) Launch production dashboard
*/
Expand Down Expand Up @@ -34,6 +35,15 @@ if (!process.env.FAILPROOFAI_DIST_PATH) {

const args = process.argv.slice(2);

// Global presentation flag: consume it before aliases, help routing, and
// subcommand validation so it works in any position.
if (args.includes("--no-color")) {
process.env.NO_COLOR = "1";
for (let i = args.length - 1; i >= 0; i--) {
if (args[i] === "--no-color") args.splice(i, 1);
}
}

// ── one noun for policies ──────────────────────────────────────────────────
// `policies`, `policy` and `pack` were three commands for one idea, two of them
// a single letter apart and doing unrelated things. They are now three
Expand Down Expand Up @@ -495,7 +505,7 @@ async function runCli() {
],
footer: [
"failproofai <command> [options] failproofai help <command> for detail",
"docs.befailproof.ai discord.befailproof.ai -h this screen -v version",
"docs.befailproof.ai discord.befailproof.ai --no-color plain output -h help -v version",
],
});
process.exit(0);
Expand Down Expand Up @@ -1808,6 +1818,7 @@ async function runCli() {
["--scope <scope>", "user, project or local. Default: user. --uninstall also takes all."],
["--beta", "Include beta policies. On --uninstall, only those."],
["--custom, -c <path>", "Custom policy file; repeat for several. Bare on --uninstall, clears every explicit path."],
["--no-color", "Suppress ANSI color output; the same as NO_COLOR=1."],
],
},
{
Expand Down