refactor: tidy and harden the config surface#15
Merged
Conversation
The `[metadata] show` table held a single boolean, inconsistent with the sibling top-level switches `theme` and `bell`. Flatten it to a top-level `metadata` key implemented as `Option<bool>` (like `bell`): `None` (key absent) and `Some(true)` render frontmatter, `Some(false)` hides it. Using `Option<bool>` keeps the derived `Default` correct — a bare `bool` would default to `false` and silently hide metadata on missing/invalid config. The frontmatter feature has not shipped in a release yet, so there is no config-compat burden. Updates config.example.toml, the CLI test, CHANGELOG, CONTEXT.md, the feature-coverage doc, and appends an amendment to ADR 0001. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two config-robustness fixes found while reviewing the rest of the config surface after the metadata flatten: - `theme` was a free `String` whose unrecognized values silently fell back to auto-detect (`resolve_theme`'s `_ => detect()`). It is now a typed `ThemeChoice` enum, so an invalid value in the config file is a hard parse error routed through `load`'s one-line warning. `--theme` gets a matching `FromStr` and warns on an unrecognized value instead of swallowing it. - Added `#[serde(deny_unknown_fields)]` to the config structs so a typo'd key (e.g. `bel` for `bell`) is reported rather than silently dropped. Both are non-breaking for valid existing configs — `theme = "dark"` etc. parse identically. The released `[font.heading]` nesting is deliberately left as-is: collapsing it would break existing user configs for a cosmetic gain. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Config-surface cleanup + hardening, prompted by noticing
[metadata]was a one-key section inconsistent with the other top-level switches.1. Flatten
metadata(cosmetic + consistency)[metadata] showwas a table holding a single boolean — inconsistent with the sibling top-level switchesthemeandbell. Flattened to a top-levelmetadatakey.Config.metadata: Option<bool>, mirroringbell:None/Some(true)show,Some(false)hides. UsingOption<bool>(not a barebool) keeps the derivedDefaultcorrect. The frontmatter feature is still unreleased, so there's no config-compat burden.2.
themeis now a typed enum (fixes a silent failure)themewas a freeString;resolve_thememapped any unrecognized value to auto-detect via a catch-all_ => detect(), so a typo liketheme = "drak"silently behaved as auto with zero feedback. It's now aThemeChoice { Auto, Dark, Light }enum:load's existing one-line warning.--theme: a matchingFromStrwarns on an unrecognized value instead of swallowing it.Non-breaking —
theme = "dark"/"light"/"auto"parse identically.3. Strict config parsing (
deny_unknown_fields)Added
#[serde(deny_unknown_fields)]to the config structs, so a typo'd key (e.g.belforbell) is reported via the invalid-config warning rather than silently ignored. The serde error names the offending key and lists the valid ones. Non-breaking for any well-formed existing config (no config key has ever been removed/renamed in a release).Deliberately NOT done: collapsing
[font.heading]→[font][font.heading]is the same "is this nesting earned?" smell as[metadata], butHeadingFontConfighas shipped since v0.1.0. Collapsing it would silently break every existing user's font config (and with #3, hard-error and drop their entire config). The reason flatteningmetadatawas free is that it was unreleased;[font.heading]is the inverse case, so it's left as-is.Tests
Added unit tests for known/invalid theme values, unknown-key rejection, and
ThemeChoice::FromStr.make checkpasses clean.🤖 Generated with Claude Code