Repository navigation
feat(cli): rledger explain — describe validation error codes - #1675
Merged
Merged
Conversation
…-explain style rledger explain E2001 prints the code's title, severity, and a hand-written explanation (meaning, common cause, fix); bare rledger explain lists all 26 codes with severities; accepts E2001/e2001/2001; unknown codes exit non-zero with a pointer to the listing. The text lives on ErrorCode itself (title/explanation via exhaustive match, so adding a variant forces adding its explanation), plus ErrorCode::from_code. Deliberately NOT include_str! from spec/core/validation.md: published crates don't package spec/ and the Nix flake's source filter strips it (the v0.17.x channel lesson); the existing error_codes_documented_in_spec test still guards code<->spec drift. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs main branch (2026-07-01)
What do these numbers mean?
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new rledger explain CLI subcommand that mirrors rustc --explain for rustledger’s validation error codes, with explanations stored as compile-time constants on rustledger_validate::ErrorCode to keep the binary self-contained and force completeness via exhaustive matches.
Changes:
- Adds
rledger explain [CODE]to print a code’s title/severity/explanation, andrledger explainto list all codes. - Extends
rustledger_validate::ErrorCodewithfrom_code(),title(), andexplanation()to back the CLI and guarantee per-variant documentation at compile time. - Adds focused unit tests for parsing, listing, unknown-code behavior, and explanation presence.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/rustledger/src/cmd/mod.rs | Registers the new explain command module. |
| crates/rustledger/src/cmd/explain.rs | Implements the rledger explain command and unit tests. |
| crates/rustledger/src/bin/rledger.rs | Wires the new Explain subcommand into the CLI dispatch. |
| crates/rustledger-validate/src/error.rs | Adds code→variant parsing plus per-code titles and long-form explanations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements improvement idea #6 —
rustc --explainfor rledger's E-codes.Design notes
ErrorCode(title()/explanation()via exhaustive match) — adding a variant forces adding its explanation at compile time. NewErrorCode::from_code.include_str!fromspec/core/validation.md: published crates don't packagespec/, and the Nix flake's crane source filter strips it (the v0.17.x channel-test lesson). The existingerror_codes_documented_in_spectest still guards code↔spec drift; explanations were sourced from the spec's per-code Condition/Severity sections.Verification
366 CLI + 94 validate tests pass (4 new: spelling roundtrip, full listing, unknown-code exit, every-code-has-substantive-explanation); smoke-tested
explain E2001/ bare /E9999; clippy-D warnings+ fmt clean.🤖 Generated with Claude Code