Standardize semantic CLI error handling
This commit is contained in:
1 parent
0b10a70924
commit
7bf40dd726
12 files changed
+153
-21
No files matched your search
@@ -17,7 +17,15 @@ describe("CLI runner", () => {
|
||||
const result = await runCli(["not-a-command"]);
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.exitCode).toBe(2);
|
||||
expect(result.stderr).toContain("Unknown command: not-a-command");
|
||||
});
|
||||
|
||||
test("returns a semantic usage exit code for invalid JSON", async () => {
|
||||
const result = await runCli(["version", "--json", "not-json"]);
|
||||
|
||||
expect(result.isError).toBe(true);
|
||||
expect(result.exitCode).toBe(2);
|
||||
expect(result.stderr).toContain("Invalid JSON:");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user