Skip to content

feat: add theme customization support - #34

Merged
unhappychoice merged 6 commits into
mainfrom
feat/theme-customization-32
Nov 10, 2025
Merged

unhappychoice merged 6 commits into
mainfrom
feat/theme-customization-32

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Nov 10, 2025 •

Copy link
Copy Markdown
Owner

close: #32

Summary

Implement comprehensive theme customization support with 9 built-in themes and configuration file management.

Changes

Built-in Themes

  • Add 8 new themes (Dracula, Nord, Solarized Dark/Light, Monokai, One Dark, Gruvbox, Catppuccin)
  • Tokyo Night remains as the default theme

Configuration System

  • Add config file support at ~/.config/gitlogue/config.toml
  • Theme priority: CLI argument > config file > default
  • Prepare infrastructure for future custom theme files

CLI Interface

  • Add theme list subcommand to display available themes
  • Add --theme <name> option to select themes

Documentation

  • Add comprehensive theme documentation in docs/themes.md
  • Update README with theme usage examples

Usage

# List all available themes
gitlogue theme list

# Use a specific theme
gitlogue --theme dracula

# Set default theme in config
echo 'theme = "nord"' > ~/.config/gitlogue/config.toml

Test plan

  • ✅ All tests pass
  • ✅ Clippy passes with no warnings
  • ✅ Code formatted with rustfmt
  • ✅ theme list command works correctly
  • ✅ Theme selection via CLI works
  • ✅ Config file loading works

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Theme system with 9 built-in themes (tokyo-night as default, dracula, nord, solarized-dark, solarized-light, monokai, one-dark, gruvbox, catppuccin)
    • Added --theme CLI option for theme selection
    • Added theme list command to view available themes
    • Configuration file support for persistent theme settings
  • Documentation

    • Added comprehensive themes documentation with usage examples
    • Updated README with theme options and controls

unhappychoice and others added 6 commits November 10, 2025 19:39
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]>
@coderabbitai

coderabbitai Bot commented Nov 10, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The 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

Cohort / File(s) Summary
Dependencies
Cargo.toml
Added dirs v5.0 dependency for user configuration directory access.
Configuration System
src/config.rs
New module introducing Config struct with theme field, load() function to read TOML config, config_path() and themes_dir() utilities for directory management.
Theme Constructors
src/theme.rs
Added eight public theme constructors (dracula(), nord(), solarized_dark(), solarized_light(), monokai(), one_dark(), gruvbox(), catppuccin()), plus load(name: &str) for dynamic theme selection and available_themes() enumeration.
CLI & Main Integration
src/main.rs
Introduced Commands and ThemeCommands enums for subcommand handling, added theme: Option<String> and command: Option<Commands> fields to Args, integrated config loading and theme precedence (CLI > config > default), added theme list subcommand support.
UI Initialization
src/ui.rs
Updated UI::new() signature to accept theme: Theme parameter and initialize UI with provided theme.
Documentation
README.md, docs/themes.md
Added user-facing documentation covering theme list/selection via CLI, config file usage, theme precedence, and planned custom theme support.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas requiring extra attention:
    • Theme color mappings in src/theme.rs — verify all 8 themes have consistent color field coverage and correct RGB/hex values
    • Configuration precedence logic in src/main.rs — ensure CLI argument correctly overrides config file and default
    • Error handling in Config::load() and Theme::load() — check that missing files and parse errors are handled gracefully with proper context messages
    • UI::new() signature change — confirm all call sites have been updated with the new theme parameter

Possibly related PRs

Poem

🎨 A rabbit hops through colored screens,
With themes of dracula, nord, and serene,
From config files to CLI might,
Tokyo nights and gruvbox light,
Customization blooms, a sight to see! 🌙

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add theme customization support' clearly and specifically summarizes the main change - adding theme customization functionality throughout the codebase.
Linked Issues check ✅ Passed The PR implements all core coding requirements: 8 new built-in themes [#32], config file loading infrastructure [#32], CLI theme option and list subcommand [#32]. Custom theme loading from config directory is noted as planned/future work.
Out of Scope Changes check ✅ Passed All changes directly support theme customization: theme implementations, config system, CLI commands, and documentation. The 'dirs' dependency and UI signature changes are necessary for config directory management and theme parameter passing.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/theme-customization-32

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/theme.rs (1)

553-567: Avoid duplicating the theme list in error messages

The “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 from available_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

📥 Commits

Reviewing files that changed from the base of the PR and between 6be423e and 6661a11.

📒 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.

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.

Add theme customization support

1 participant