Skip to content

Commit 125a559

Browse files
feat: add config file support for color mode selection
- Implement priority hierarchy for color mode selection: 1. CLI arguments (highest priority) 2. Configuration file settings 3. Auto-detection (lowest priority) - Check config.terminal.color_mode for 'rgb' or '256' values - Fall back to auto-detection if not explicitly configured - Add clarifying comments about the priority order This allows users to persist their preferred color mode in the configuration file while still respecting CLI overrides.
1 parent e2b9e1a commit 125a559

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ fn main() -> Result<()> {
136136
}
137137

138138
// Detect terminal capabilities and determine color mode
139+
// Priority: CLI args > config file > auto-detection
139140
let caps = treemd::tui::TerminalCapabilities::detect();
140141
let color_mode = if let Some(ref mode_arg) = args.color_mode {
142+
// CLI flag takes highest priority
141143
use cli::ColorModeArg;
142144
use treemd::tui::ColorMode;
143145
match mode_arg {
@@ -146,7 +148,14 @@ fn main() -> Result<()> {
146148
ColorModeArg::Color256 => ColorMode::Indexed256,
147149
}
148150
} else {
149-
caps.recommended_color_mode
151+
// Check config file setting before falling back to auto-detection
152+
use treemd::tui::ColorMode;
153+
match config.terminal.color_mode.as_str() {
154+
"rgb" => ColorMode::Rgb,
155+
"256" => ColorMode::Indexed256,
156+
// "auto" or any other value falls back to detection
157+
_ => caps.recommended_color_mode,
158+
}
150159
};
151160

152161
// Show compatibility warning if needed (before TUI init)

0 commit comments

Comments
 (0)