Skip to content

feat(cli): define and enforce exit-code policy#34

Merged
alexengrig merged 2 commits into
mainfrom
cursor/exit-code-policy-a64c
Jul 5, 2026
Merged

feat(cli): define and enforce exit-code policy#34
alexengrig merged 2 commits into
mainfrom
cursor/exit-code-policy-a64c

Conversation

@alexengrig

Copy link
Copy Markdown
Member

Summary

Implements #15 by defining and enforcing a consistent CLI exit-code policy:

Code Meaning
0 Success
1 Command outcome failure
2 CLI usage error

Changes

  • Add CliExitCode enum and named constants in crates/adrman-cli/src/exit_code.rs
  • Route all command handlers and parser error handling through the policy
  • Classify adr new missing title and extra title tokens as usage errors (2)
  • Parse adr check --format with clap value_parser so unsupported values are usage errors
  • Add exit_code_command integration tests covering representative 0/1/2 cases
  • Document the policy in README and OpenSpec (cli-root, cli-new)

Testing

  • cargo test --workspace
  • cargo clippy --workspace --all-targets
  • cargo fmt --check

Closes #15

Open in Web Open in Cursor 

Introduce CliExitCode enum (0 success, 1 outcome failure, 2 usage error)
and route parser and command handlers through it.

- Classify adr new missing title and extra args as usage errors (exit 2)
- Parse adr check --format via clap value_parser
- Add exit_code_command integration tests
- Document policy in README and OpenSpec specs

Closes #15

Co-authored-by: Grig Alex <alexengrigdev@gmail.com>

@alexengrig alexengrig left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursor Thanks, this is close and matches the #15 policy direction well. One blocking issue remains: CI is failing in the clippy step, and the unused CheckOutputFormat import in main.rs appears to be the cause after run_check moved format parsing into cli.rs.

Please remove that unused import and rerun the checks.

Comment thread crates/adrman-cli/src/main.rs Outdated
@cursor

cursor Bot commented Jul 5, 2026

Copy link
Copy Markdown

Fixed the CI clippy failure and pushed to PR #34.

Changes:

  • Removed CheckOutputFormat from main.rs by adding CheckArgs::output_format() in cli.rs (default format resolution stays next to clap parsing).
  • Added #[allow(dead_code)] on the shared test CliRun impl — exit_code_command only uses a subset of helpers, which triggered -D warnings under --all-targets.

Checks passed:

  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo test --workspace
  • cargo fmt --check
Open in Web Open in Cursor 

Move default format resolution into CheckArgs::output_format() in cli.rs
and allow dead_code on shared test support helpers used selectively.

Co-authored-by: Grig Alex <alexengrigdev@gmail.com>

@alexengrig alexengrig left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good now. The previous unused import issue is fixed, the review thread is resolved, CI is green, and the exit-code policy implementation matches #15.

@alexengrig alexengrig added this to the v0.1.0 milestone Jul 5, 2026
@alexengrig alexengrig self-assigned this Jul 5, 2026
@alexengrig
alexengrig marked this pull request as ready for review July 5, 2026 22:34
@cursor

cursor Bot commented Jul 5, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@alexengrig
alexengrig merged commit 70afa7c into main Jul 5, 2026
1 check passed
@alexengrig
alexengrig deleted the cursor/exit-code-policy-a64c branch July 5, 2026 22:37
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.

Define and enforce CLI exit-code policy

2 participants