fix(cli): let theme show accept custom theme file paths again - #407
Merged
Conversation
theme show validates its argument against ListThemes so a typo errors instead of silently printing the default theme. ListThemes only returns built-in names, so that check also rejected the documented path form: grut theme show ./my-theme.toml Error: unknown theme "./my-theme.toml" (available: catppuccin, default, ...) theme.Load explicitly supports path arguments and reads them from disk, and docs/configuration.md documents the form, so this made a documented feature unusable. Skip the built-in list check when the argument looks like a path and let Load handle it, so a bad path surfaces the real loader error rather than a misleading list of built-in names. Unknown bare names are still rejected exactly as before. looksLikePath is exported as LooksLikePath rather than reimplemented in cmd, so the two places that decide what counts as a path cannot drift apart. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c5a9c45a-0341-46e5-8458-f4060ddd58c7
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.
Problem
theme showvalidates its argument againstListThemes()so a typo errors outinstead of silently printing the default theme (added in #404).
ListThemes()only returns built-in names, so that check also rejected the documented path
form:
theme.Loadexplicitly supports path arguments and reads them from disk, anddocs/configuration.mddocuments the form. So a documented feature becameunusable, and the error message actively misled by implying only built-ins
exist.
Regression is from this unreleased window, so no released version is affected.
Fix
Skip the built-in list check when the argument looks like a path, and let
theme.Loadhandle it. A bad path now surfaces the real loader error instead ofa misleading list of built-in names.
looksLikePathis exported asLooksLikePathrather than reimplemented incmd, so the two places that decide what counts as a path cannot drift apart.Verification
Confirmed end to end that the path form reaches the loader and reports real file
errors:
Unknown bare names are still rejected exactly as before:
New tests cover four path shapes (relative,
./-prefixed, absolute POSIX,Windows), that the argument reaches
loadunchanged, and that a load failurepropagates rather than being masked as "unknown theme". Full
cmdandinternal/themesuites pass.