Skip to content

refactor: move exit codes to shared package#27

Merged
rianjs merged 1 commit intomainfrom
refactor/15-exit-codes-to-shared
Jan 29, 2026
Merged

refactor: move exit codes to shared package#27
rianjs merged 1 commit intomainfrom
refactor/15-exit-codes-to-shared

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Jan 29, 2026

Summary

  • Create shared/exitcode package with standardized exit codes
  • Update jtk to use shared exitcode package
  • Update cfl to use shared exitcode package (replaces hardcoded os.Exit(1))
  • Remove jtk/internal/exitcode package

Exit Codes

Code Name Description
0 Success Command completed successfully
1 GeneralError Unspecified error
2 UsageError Invalid command-line usage
3 ConfigError Configuration problem
4 AuthError Authentication failure
5 NotFoundError Resource not found
6 PermissionError Insufficient permissions
7 RateLimitError API rate limiting
8 ServerError Server-side error

Test plan

  • Build succeeds
  • All tests pass
  • Lint passes

Closes #15

🤖 Generated with Claude Code

- Create shared/exitcode package with standardized exit codes
- Update jtk to use shared exitcode package
- Update cfl to use shared exitcode package (replaces hardcoded 1)
- Remove jtk/internal/exitcode package

Both CLI tools now use consistent exit codes for better scripting support.

Closes #15
@rianjs
Copy link
Copy Markdown
Contributor Author

rianjs commented Jan 29, 2026

Test Coverage Assessment

Summary

Verdict: Test coverage is adequate for this change.

This PR moves exit code constants from tools/jtk/internal/exitcode to shared/exitcode and updates both cfl and jtk to use the shared package.

Analysis

What Changed:

  1. Created shared/exitcode/exitcode.go - a package of constant integer definitions
  2. Updated tools/cfl/cmd/cfl/main.go to use exitcode.GeneralError instead of hardcoded 1
  3. Updated tools/jtk/cmd/jtk/main.go to import from the shared package instead of the internal one
  4. Deleted tools/jtk/internal/exitcode/exitcode.go

Why Tests Are Not Required:

  1. Pure Constants: The exitcode package contains only constant definitions (const Success = 0, const GeneralError = 1, etc.). These are compile-time values with no logic, branching, or behavior to test. Testing that GeneralError == 1 would be tautological.

  2. No Behavior to Verify: Unlike the shared/errors package (which has parsing, formatting, and error wrapping logic), exitcode has no methods, no state, and no transformation logic.

  3. Deleted Package Had No Tests: The original tools/jtk/internal/exitcode package had no tests, and that was appropriate for the same reason - it's just constants.

  4. Integration Verified by Build: The PR's test plan confirms the build succeeds, meaning the import paths are correct and the constants are accessible. This is the meaningful verification for a constants-only package.

For Reference:
The existing test suites for cfl and jtk will continue to exercise code paths that use these exit codes. If any constant were incorrectly defined, existing tests exercising error handling would fail.

Verdict

No additional tests needed. The change is a straightforward refactor to share constants between tools, and the existing CI pipeline (build + existing tests) provides sufficient verification.

@rianjs rianjs merged commit 111c070 into main Jan 29, 2026
7 checks passed
@rianjs rianjs deleted the refactor/15-exit-codes-to-shared branch January 29, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: move exit codes to shared package

1 participant