Repository navigation
Add include_optional and CLI --theme precedence - #342
Merged
Merged
Conversation
Support optional config/theme includes, missing-path error context, and CLI --theme override precedence for retch v0.23.0: - Add `include_optional` (string or array) merged after required `include` files and before the including file's own keys; skip only `ErrorKind::NotFound` while still failing on directories, permission errors, invalid TOML, empty paths, size/depth limits, cycles, and nested required `include` failures - Attach path context via `anyhow::Context` in `read_config_bytes` - Ignore `[custom_theme]` overrides when `--theme <name>` is passed on the CLI with any value other than `"custom"` (`Config::merge_with_cli` and `display::resolve_theme`) - Add unit and CLI integration tests covering `include_optional`, error context, `--merge-config` doc safety, and `--theme` precedence - Fix `packaging/homebrew/retch.rb` header comment exceeding Homebrew's 118-char line limit when rendered, and enforce line length in `scripts/render_packaging.py --self-test` - Bump `retch-cli` to `0.23.0`, update `Cargo.lock`, regenerate `docs/retch.1`, and update `README.md` and `NOTES.md` Assisted-By: Gemini
l1a
force-pushed
the
feature/include-optional
branch
from
November 20, 2026 23:50
4f4ca5a to
35b1603
Compare
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.
Summary
Adds
include_optional, path error context on config/include file reads, and CLI--themeoverride precedence inretch(v0.23.0) so external theme engines (such as Noctalia) can manage a color fragment cleanly.What changed
include_optional(src/config.rs,src/main.rs):include(left-to-right) <include_optional(left-to-right) < including file.std::io::ErrorKind::NotFound; directories, non-regular files, permission errors, oversized files (> 1 MiB), invalid TOML, empty path entries, depth overflow (> 8), cycles, and missing nested requiredincludetargets still fail loudly.DEFAULT_INCLUDE_OPTIONAL_BLOCKto--generate-config,--write-config, and--merge-configwithout using any other key'sname =assignment syntax in comments.src/config.rs):read_config_bytesattaches.with_context(|| format!("Failed to read config {}", path.display()))on metadata/open/read failures so errors always identify the offending file.--themeprecedence (src/config.rs,src/display.rs):display::resolve_themeand updatedConfig::merge_with_cliso passing--theme <name>(for any value other than"custom", case-insensitive) ignores[custom_theme]overrides from config files while preserving--theme custom.Cargo.toml,Cargo.lock,docs/retch.1.md,docs/retch.1,README.md,NOTES.md,retch.wiki):retch-clito0.23.0(retch-sysinfounchanged at0.1.111), regenerateddocs/retch.1, and updated documentation (includingConfiguration-and-Theming.mdinretch.wiki).Test plan
just checkpasses (cargo fmt -- --check,cargo clippy --workspace -- -D warnings,cargo clippy -p retch-cli --no-default-features -- -D warnings,man_pages.py, packaging/metadata/text/wip/bench checks)cargo test --workspacepasses (including newinclude_optional, error-context,--merge-config, and CLI--themeprecedence unit tests insrc/config.rsandsrc/display.rs, plustest_cli_include_optional_and_theme_overrideintests/cli_tests.rs)config.tomlsettinginclude_optional = "themes/noctalia.toml"(both when the fragment is absent and when present) and confirmretch --theme solarized-darkoverrides it whileretch --theme customkeeps itNote
Medium Risk
Changes config merge semantics and theme resolution paths users rely on for theming, but does not touch auth, network payloads, or privileged operations beyond clearer config read errors.
Overview
Bumps
retch-clito0.23.0and refines howconfig.tomlloads fragments and applies themes for external template workflows (e.g. Noctalia).include_optionalmerges likeinclude, but onlyNotFoundis ignored; invalid TOML, cycles, oversized files, and nested requiredincludefailures still error. Merge order is requiredinclude→include_optional→ this file, with empty path strings rejected.CLI
--theme(any name except"custom", case-insensitive) now wins over[custom_theme]from included files viaresolve_themeindisplay.rsand by clearingcustom_themeinConfig::merge_with_cli.Config I/O errors attach the offending path through
anyhow::Contextinread_config_bytes. Docs, man page, and default config templates documentinclude_optional; Homebrew packaging avoids literal@TOKEN@in comments andrender_packaging.py --self-testenforces rendered formula lines ≤ 118 characters.Reviewed by Cursor Bugbot for commit 35b1603. Bugbot is set up for automated code reviews on this repo. Configure here.