applyTheme applies the theme, resolving it from the --theme flag, then the user config, then the built-in default.
(themeOverride string)
| 1129 | // applyTheme applies the theme, resolving it from the --theme flag, then the |
| 1130 | // user config, then the built-in default. |
| 1131 | func applyTheme(themeOverride string) { |
| 1132 | // Resolve theme from --theme flag > user config > built-in default |
| 1133 | themeRef := styles.DefaultThemeRef |
| 1134 | if userSettings := userconfig.Get(); userSettings.Theme != "" { |
| 1135 | themeRef = userSettings.Theme |
| 1136 | } |
| 1137 | if themeOverride != "" { |
| 1138 | themeRef = themeOverride |
| 1139 | } |
| 1140 | |
| 1141 | theme, err := styles.LoadTheme(themeRef) |
| 1142 | if err != nil { |
| 1143 | slog.Warn("Failed to load theme, using default", "theme", themeRef, "error", err) |
| 1144 | theme = styles.DefaultTheme() |
| 1145 | } |
| 1146 | |
| 1147 | styles.ApplyTheme(theme) |
| 1148 | slog.Debug("Applied theme", "theme_ref", themeRef, "theme_name", theme.Name) |
| 1149 | } |