Repository navigation
feat: add theme customization support - #34
Conversation
Add dirs crate to enable cross-platform config directory detection for theme configuration files.
Add configuration file support to load theme preferences from ~/.config/gitlogue/config.toml. Includes helper functions for config path and themes directory (for future custom theme support). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add support for multiple color themes: - Dracula: vibrant dark theme - Nord: arctic-inspired palette - Solarized Dark/Light: popular precision colors - Monokai: classic warm colors - One Dark: Atom-inspired theme - Gruvbox: retro groove colors - Catppuccin: soothing pastel theme (Mocha) Implement Theme::load() to select themes by name and Theme::available_themes() to list all options. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Modify UI::new() to accept a Theme parameter instead of using Theme::default(), enabling runtime theme selection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add 'theme list' subcommand to display available themes. Add --theme option to override the default theme. Theme loading priority: 1. CLI argument (--theme) 2. Config file (~/.config/gitlogue/config.toml) 3. Default theme (tokyo-night) Usage: - gitlogue theme list - gitlogue --theme dracula 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add comprehensive theme documentation in docs/themes.md covering: - List of all 9 built-in themes - Usage instructions for theme selection - Configuration file format - Theme priority order Update README.md to highlight theme support feature and add usage examples for the theme subcommand. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
WalkthroughThe PR adds theme customization support by implementing eight built-in themes (Dracula, Nord, Solarized variants, Monokai, One Dark, Gruvbox, Catppuccin) alongside a configuration system that loads theme preferences from TOML files. It introduces CLI arguments for theme selection, a theme management subcommand, and integrates theme loading with precedence handling (CLI override > config file > default). Changes
Sequence DiagramsequenceDiagram
participant User
participant Main as main()
participant Config as Config
participant Theme as Theme
participant UI as UI
User->>Main: Run gitlogue [--theme THEME] [subcommand]
Main->>Config: Config::load()
Config-->>Main: Config { theme }
alt Theme Subcommand
Main->>Theme: Theme::available_themes()
Theme-->>Main: Vec of theme names
Main->>User: Print themes & exit
else Normal Flow
alt CLI theme provided
Main->>Theme: Theme::load(cli_theme)
Theme-->>Main: Theme
else Config theme provided
Main->>Theme: Theme::load(config_theme)
Theme-->>Main: Theme
else Use default
Main->>Theme: Theme::default()
Theme-->>Main: Theme (tokyo-night)
end
Main->>UI: UI::new(speed, is_commit, repo, theme)
UI->>UI: Initialize with theme colors
UI-->>Main: UI instance
Main->>User: Display UI with selected theme
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/theme.rs (1)
553-567: Avoid duplicating the theme list in error messagesThe “unknown theme” branch now hardcodes the list of valid names in three separate places (match arms,
available_themes, and this error string). The message will go stale the next time we add a theme and forget to update this literal. Please build the message directly fromavailable_themes()so it always stays in sync.- _ => Err(anyhow::anyhow!("Unknown theme: {}", name)) - .context("Available themes: tokyo-night, dracula, nord, solarized-dark, solarized-light, monokai, one-dark, gruvbox, catppuccin"), + _ => { + let available = Self::available_themes().join(", "); + Err(anyhow::anyhow!( + "Unknown theme: {} (available themes: {})", + name, + available + )) + }src/main.rs (1)
50-56: LGTM with optional UX enhancement.The theme CLI argument is properly structured with clear help text. The implementation correctly prioritizes CLI over config file.
Consider normalizing theme names to lowercase in
Theme::load()to improve UX. Currently, users must use exact lowercase names like"dracula"rather than"Dracula"or"DRACULA".Example enhancement in
Theme::load():pub fn load(name: &str) -> Result<Self> { let normalized_name = name.to_lowercase(); match normalized_name.as_str() { // ... existing match arms } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
Cargo.toml(1 hunks)README.md(2 hunks)docs/themes.md(1 hunks)src/config.rs(1 hunks)src/main.rs(4 hunks)src/theme.rs(2 hunks)src/ui.rs(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/main.rs (2)
src/theme.rs (2)
available_themes(571-583)load(554-568)src/ui.rs (1)
new(46-67)
🔇 Additional comments (5)
src/main.rs (5)
2-2: LGTM: Module and import additions are clean.The new imports for configuration and theme modules are properly organized and all are used in the updated main flow.
Also applies to: 10-11, 14-14
62-75: LGTM: Subcommand structure follows Clap best practices.The nested subcommand structure for theme management is well-organized and includes helpful documentation comments.
102-115: LGTM: Subcommand handling is correctly placed.The theme list command is properly handled before repository validation, allowing users to list themes without needing to be in a git repository. The early return is appropriate.
140-140: LGTM: UI initialization properly updated.The UI::new call correctly passes the loaded theme, matching the updated API signature shown in the relevant code snippets.
122-125: LGTM: Theme loading precedence is well-implemented.The theme selection logic correctly implements the documented precedence (CLI > config > default), and
Config::load()already handles error cases well: missing config files gracefully fall back to defaults, while malformed existing files are rejected with descriptive errors. The code is clear, matches the PR objectives, and follows good UX practices.
close: #32
Summary
Implement comprehensive theme customization support with 9 built-in themes and configuration file management.
Changes
Built-in Themes
Configuration System
~/.config/gitlogue/config.tomlCLI Interface
theme listsubcommand to display available themes--theme <name>option to select themesDocumentation
docs/themes.mdUsage
Test plan
theme listcommand works correctly🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
--themeCLI option for theme selectiontheme listcommand to view available themesDocumentation