MCPcopy Index your code
hub / github.com/docker/docker-agent / SaveThemeToUserConfig

Function SaveThemeToUserConfig

pkg/tui/styles/theme.go:485–507  ·  view source on GitHub ↗

SaveThemeToUserConfig persists the theme reference to the user config file. If themeRef equals DefaultThemeRef, the setting is cleared (empty string).

(themeRef string)

Source from the content-addressed store, hash-verified

483// SaveThemeToUserConfig persists the theme reference to the user config file.
484// If themeRef equals DefaultThemeRef, the setting is cleared (empty string).
485func SaveThemeToUserConfig(themeRef string) error {
486 cfg, err := userconfig.Load()
487 if err != nil {
488 return fmt.Errorf("loading user config: %w", err)
489 }
490
491 if cfg.Settings == nil {
492 cfg.Settings = &userconfig.Settings{}
493 }
494
495 // Clear the setting if using the default theme
496 if themeRef == DefaultThemeRef {
497 cfg.Settings.Theme = ""
498 } else {
499 cfg.Settings.Theme = themeRef
500 }
501
502 if err := cfg.Save(); err != nil {
503 return fmt.Errorf("saving user config: %w", err)
504 }
505
506 return nil
507}
508
509// GetPersistedThemeRef returns the theme reference persisted in user config.
510// Returns DefaultThemeRef if no theme is set or if loading fails.

Callers 1

handleChangeThemeMethod · 0.92

Calls 2

LoadFunction · 0.92
SaveMethod · 0.80

Tested by

no test coverage detected