Skip to content

feat: implement configuration file support - #43

Merged
unhappychoice merged 11 commits into
mainfrom
feat/implement-configuration-file-support
Nov 11, 2025
Merged

unhappychoice merged 11 commits into
mainfrom
feat/implement-configuration-file-support

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Nov 11, 2025 •

Copy link
Copy Markdown
Owner

close: #11

Summary

  • Implement TOML configuration file support at ~/.config/gitlogue/config.toml
  • Add theme set command to update default theme while preserving user comments
  • Support theme, speed, and background options in config file
  • CLI arguments take precedence over config file values

Changes

Added

  • toml_edit dependency for comment-preserving config updates
  • Config::save() method that preserves user comments in TOML file
  • theme set <name> subcommand to update default theme
  • Support for speed and background options in config file

Changed

  • CLI arguments (speed, background) made optional to allow config file fallback
  • Config file format changed from YAML to TOML for better comment preservation
  • Config file path: ~/.config/gitlogue/config.toml

Documentation

  • Added Configuration section to README with examples
  • Documented config file location, format, and priority

Implementation Details

Comment Preservation

Using toml_edit::DocumentMut to parse and update TOML while preserving:

  • User-added comments
  • Inline comments
  • Formatting and whitespace

Configuration Priority

  1. CLI arguments (highest priority)
  2. Configuration file
  3. Default values (lowest priority)

Example Usage

# Set default theme
gitlogue theme set dracula

# Config file will preserve user comments
# ~/.config/gitlogue/config.toml:
# My custom comment here
theme = "dracula"  # inline comment preserved
speed = 30
background = true

Test Plan

  • cargo check
  • cargo test
  • cargo clippy
  • cargo fmt
  • Verified comment preservation when updating config
  • Verified new config creation with default comments
  • Verified invalid theme name handling

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Persistent config file at ~/.config/gitlogue/config.toml
    • New command to set and persist the default theme
    • Configurable speed and background options persisted to config
  • Improvements

    • CLI arguments override config file; precedence: CLI > config > defaults
    • Speed and background can be omitted from CLI to use saved or default values
    • Theme transparency now respects resolved background setting
  • Documentation

    • Added Configuration Guide and updated Quick Start with theme example

unhappychoice and others added 4 commits November 12, 2025 04:23
- Add Config::save() method using toml_edit
- Preserve user comments when updating config values
- Support speed and background options in addition to theme
- Change config path from config.yaml to config.toml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add 'theme set' subcommand to update default theme
- Make CLI args optional to allow config file fallback
- Merge config values with CLI arguments (CLI takes precedence)
- Validate theme exists before saving to config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Document config file location and format (TOML)
- Add example configuration with all options
- Explain configuration priority (CLI > config > defaults)
- Add theme set command usage example

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 11, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@unhappychoice has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 25 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4754146 and 92a968c.

📒 Files selected for processing (1)
  • README.md (4 hunks)

Walkthrough

Configuration support extended: new speed and background fields on Config, a Config::save() implementation that preserves comments using toml_edit, CLI args for speed/background made optional with config-file fallback, a theme set subcommand to persist the default theme, and toml_edit = "0.22" added to Cargo.toml.

Changes

Cohort / File(s) Summary
Dependency Addition
Cargo.toml
Added toml_edit = "0.22" to enable editing TOML while preserving comments.
Documentation
README.md, docs/configuration.md
Added Configuration section and a dedicated Configuration Guide documenting TOML config at ~/.config/gitlogue/config.toml, precedence rules (CLI > config > defaults), options (theme, speed, background), examples, and troubleshooting.
Config Structure & Persistence
src/config.rs
Added pub speed: u64 and pub background: bool; added default_speed() and default_background() helpers; updated Default impl to include new fields; implemented pub fn save(&self) -> Result<()> which reads/updates existing config with toml_edit (preserving comments) or creates a new commented config file.
CLI & Precedence Logic
src/main.rs
Changed Args.speed and Args.background to Option<u64> / Option<bool> (CLI may override config); added ThemeCommands::Set { name }; implemented logic to load/create config, resolve final speed and background values with CLI taking precedence, apply resolved values to UI, and persist theme via config.save() when theme set is used.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Config
    participant FS

    rect rgb(220, 235, 255)
    Note over User,CLI: Resolve configuration precedence
    end

    User->>CLI: gitlogue --speed 60 --background false
    CLI->>Config: load() from ~/.config/gitlogue/config.toml
    Config->>FS: read file
    FS-->>Config: return TOML (or not found)
    alt CLI values provided
        CLI->>Config: use CLI speed/background
    else Config file has values
        Config->>CLI: use config values
    else
        Config->>CLI: use defaults
    end
    CLI->>UI: instantiate with resolved speed/background
    UI-->>User: render

    rect rgb(220, 255, 230)
    Note over User,Config: Persist theme via `theme set`
    end

    User->>CLI: gitlogue theme set dracula
    CLI->>Config: validate "dracula" exists
    CLI->>Config: load or create config
    Config->>FS: parse or create TOML (toml_edit)
    Config->>FS: write updated config (preserve comments)
    FS-->>Config: write success
    CLI-->>User: print config path
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring attention:

  • src/config.rs — Config::save() (toml_edit usage, comment preservation, error handling, file creation path)
  • src/main.rs — precedence resolution and applying resolved values to UI, and theme set handler validation/persistence
  • README/docs — ensure documentation matches implemented defaults and CLI help text

Possibly related PRs

Poem

🐰
Speed and backdrop tucked in TOML neat,
CLI whispers, files and defaults meet.
A theme is set, then saved with care—
Comments stay, the rabbit hops in air. ✨

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: implement configuration file support' accurately and concisely summarizes the main change—adding TOML configuration file support to the gitlogue application.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issue #11: config structure with serde, file loading from home directory, CLI precedence over config values, graceful error handling, and comprehensive documentation.
Out of Scope Changes check ✅ Passed All changes align with issue #11 objectives. The addition of toml_edit dependency and documentation updates are directly necessary for implementing configuration file support with comment preservation.

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.

unhappychoice and others added 7 commits November 12, 2025 04:26
Create comprehensive configuration documentation covering:
- Config file format and location
- All available options with examples
- Configuration priority (CLI > config > defaults)
- Comment preservation feature
- Troubleshooting tips

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Move detailed configuration info to docs/configuration.md.
Keep README concise with link to detailed guide.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Improve README structure by showing features earlier.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

Implement configuration file support

1 participant