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

Function validateTheme

cmd/root/run.go:1119–1127  ·  view source on GitHub ↗

validateTheme reports whether ref names a loadable theme. It is used to fail fast on an explicit --theme value, listing the available themes so the user can correct a typo.

(ref string)

Source from the content-addressed store, hash-verified

1117// fail fast on an explicit --theme value, listing the available themes so the
1118// user can correct a typo.
1119func validateTheme(ref string) error {
1120 if _, err := styles.LoadTheme(ref); err != nil {
1121 if refs, listErr := styles.ListThemeRefs(); listErr == nil && len(refs) > 0 {
1122 return fmt.Errorf("unknown theme %q; available themes: %s", ref, strings.Join(refs, ", "))
1123 }
1124 return fmt.Errorf("unknown theme %q: %w", ref, err)
1125 }
1126 return nil
1127}
1128
1129// applyTheme applies the theme, resolving it from the --theme flag, then the
1130// user config, then the built-in default.

Callers 2

TestValidateThemeFunction · 0.85
runRunCommandMethod · 0.85

Calls 2

LoadThemeFunction · 0.92
ListThemeRefsFunction · 0.92

Tested by 1

TestValidateThemeFunction · 0.68