Skip to content

fix(cli): let theme show accept custom theme file paths again - #407

Merged
jongio merged 1 commit into
mainfrom
fix/theme-show-path-form
Aug 5, 2026
Merged

fix(cli): let theme show accept custom theme file paths again#407
jongio merged 1 commit into
mainfrom
fix/theme-show-path-form

Conversation

@jongio

@jongio jongio commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Problem

theme show validates its argument against ListThemes() so a typo errors out
instead of silently printing the default theme (added in #404). 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, gruvbox, tokyonight)

theme.Load explicitly supports path arguments and reads them from disk, and
docs/configuration.md documents the form. So a documented feature became
unusable, 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.Load handle it. A bad path now surfaces the real loader error instead of
a misleading list of built-in names.

looksLikePath is exported as LooksLikePath rather than reimplemented in
cmd, 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:

$ grut theme show /tmp/custom.toml
Error: theme "/tmp/custom.toml": missing color values: foreground, cursor, ...

Unknown bare names are still rejected exactly as before:

$ grut theme show grubvox
Error: unknown theme "grubvox" (available: catppuccin, default, gruvbox, tokyonight)

New tests cover four path shapes (relative, ./-prefixed, absolute POSIX,
Windows), that the argument reaches load unchanged, and that a load failure
propagates rather than being masked as "unknown theme". Full cmd and
internal/theme suites pass.

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
@jongio
jongio merged commit e0b278f into main Aug 5, 2026
4 checks passed
@jongio
jongio deleted the fix/theme-show-path-form branch August 5, 2026 14:55
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.

1 participant