Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyThemePreset(v *viper.Viper) error
- func LoadViper() (*viper.Viper, error)
- func NewViper() *viper.Viper
- type Color
- func (c Color) MarshalText() (text []byte, err error)
- func (c Color) Render(s string) string
- func (c *Color) Set(text string) error
- func (c Color) Sprint(args ...any) string
- func (c Color) Sprintf(format string, args ...any) string
- func (c Color) Sprintln(args ...any) string
- func (c Color) String() string
- func (c *Color) UnmarshalText(text []byte) error
- type ColorSlice
- type Config
- type Preset
- type Theme
- type ThemeApply
- type ThemeBase
- type ThemeData
- type ThemeDataRatio
- type ThemeDescribe
- type ThemeExplain
- type ThemeOptions
- type ThemeStatus
- type ThemeStderr
- type ThemeTable
- type ThemeVersion
Constants ¶
const PresetKey = "preset"
PresetKey is the Viper config key to use in viper.Viper.Set.
Variables ¶
var ( PresetDefault = PresetDark // AllPresets is used in parsing and places like the // internal/cmd/configschema package to show all available options. AllPresets = []Preset{ PresetNone, PresetDark, PresetLight, PresetProtDark, PresetProtLight, PresetDeutDark, PresetDeutLight, PresetTritDark, PresetTritLight, PresetPre030Dark, PresetPre030Light, PresetPre0021Dark, PresetPre0021Light, } )
Functions ¶
func ApplyThemePreset ¶
Types ¶
type Color ¶
func MustParseColor ¶
func ParseColor ¶
func (Color) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (Color) Sprint ¶
Sprint returns the stringified args (concatenated right after each other) wrapped in color codes from this color.
func (Color) Sprintln ¶
Sprintln returns the stringified args (concatenated right after each other) wrapped in color codes from this color, as well as a trailing newline. The newline character is added after the color reset.
func (*Color) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type ColorSlice ¶
type ColorSlice []Color
func MustParseColorSlice ¶
func MustParseColorSlice(s string) ColorSlice
func ParseColorSlice ¶
func ParseColorSlice(s string) (ColorSlice, error)
func (ColorSlice) MarshalText ¶
func (s ColorSlice) MarshalText() (text []byte, err error)
MarshalText implements encoding.TextMarshaler.
func (ColorSlice) String ¶
func (s ColorSlice) String() string
func (*ColorSlice) UnmarshalText ¶
func (s *ColorSlice) UnmarshalText(text []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type Config ¶
type Config struct { Debug bool `jsonschema:"-"` Kubectl string `jsonschema:"default=kubectl,example=kubectl1.19,example=oc"` // Which kubectl executable to use ObjFreshThreshold time.Duration // Ages below this uses theme.data.durationfresh coloring Preset Preset // Color theme preset Theme Theme }
type Preset ¶
type Preset string
const ( // "Zero value", i.e empty theme selected PresetNone Preset = "" // Default themes PresetDark Preset = "dark" PresetLight Preset = "light" // Color blind focused themes PresetProtDark Preset = "protanopia-dark" PresetProtLight Preset = "protanopia-light" PresetDeutDark Preset = "deuteranopia-dark" PresetDeutLight Preset = "deuteranopia-light" PresetTritDark Preset = "tritanopia-dark" PresetTritLight Preset = "tritanopia-light" // Pre-v0.3.0 PresetPre030Dark Preset = "pre-0.3.0-dark" PresetPre030Light Preset = "pre-0.3.0-light" // Pre-v0.0.21 PresetPre0021Dark Preset = "pre-0.0.21-dark" PresetPre0021Light Preset = "pre-0.0.21-light" )
func ParsePreset ¶
func (Preset) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Preset) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Theme ¶
type Theme struct { // Base colors must be first so they're applied first Base ThemeBase // base colors for themes Default Color // default when no specific mapping is found for the command Data ThemeData // colors for representing data Status ThemeStatus // generic status coloring (e.g "Ready", "Terminating") Table ThemeTable // used in table output, e.g "kubectl get" and parts of "kubectl describe" Stderr ThemeStderr // used in kubectl's stderr output Describe ThemeDescribe // used in "kubectl describe" Apply ThemeApply // used in "kubectl apply" Explain ThemeExplain // used in "kubectl explain" Options ThemeOptions // used in "kubectl options" Version ThemeVersion // used in "kubectl version" }
Theme is the root theme config.
func NewBaseTheme ¶
NewBaseTheme returns the base color schema depending on the dark/light setting
type ThemeApply ¶
type ThemeApply struct { Created Color `defaultFrom:"theme.base.success"` // used on "deployment.apps/foo created" Configured Color `defaultFrom:"theme.base.warning"` // used on "deployment.apps/bar configured" Unchanged Color `defaultFrom:"theme.base.primary"` // used on "deployment.apps/quux unchanged" DryRun Color `defaultFrom:"theme.base.secondary"` // used on "deployment.apps/quux created (dry-run)" Fallback Color `defaultFrom:"theme.base.success"` // used when "kubectl apply" outputs unknown format }
ThemeApply holds colors for the "kubectl apply" output.
type ThemeBase ¶
type ThemeBase struct { Info Color // general color for when things are informational Primary Color // general color for when things are focus Secondary Color // general color for when things are secondary focus Success Color // general color for when things are good Warning Color // general color for when things are wrong Danger Color // general color for when things are bad Muted Color // general color for when things are less relevant Key ColorSlice `defaultFromMany:"theme.base.secondary"` // general color for keys }
ThemeBase contains base colors that other theme fields can default to, just to make overriding themes easier.
These fields should never be referenced in the printers. Instead, they should use the more specific fields, such as [ThemeApply.Created]
type ThemeData ¶
type ThemeData struct { Key ColorSlice `defaultFrom:"theme.base.key"` // used for the key String Color `defaultFrom:"theme.base.info"` // used when value is a string True Color `defaultFrom:"theme.base.success"` // used when value is true False Color `defaultFrom:"theme.base.danger"` // used when value is false Number Color `defaultFrom:"theme.base.primary"` // used when the value is a number Null Color `defaultFrom:"theme.base.muted"` // used when the value is null, nil, or none Quantity Color `defaultFrom:"theme.data.number"` // used when the value is a quantity, e.g "100m" or "5Gi" Duration Color `` // used when the value is a duration, e.g "12m" or "1d12h" DurationFresh Color `defaultFrom:"theme.base.success"` // color used when the time value is under a certain delay Ratio ThemeDataRatio }
ThemeData holds colors for when representing parsed data. Such as in YAML, JSON, and even some "kubectl describe" values
type ThemeDataRatio ¶
type ThemeDescribe ¶
type ThemeDescribe struct {
Key ColorSlice `defaultFrom:"theme.base.key"` // used on keys. The multiple colors are cycled based on indentation.
}
ThemeApply holds colors for the "kubectl apply" output.
type ThemeExplain ¶
type ThemeExplain struct { Key ColorSlice `defaultFrom:"theme.base.key"` // used on keys. The multiple colors are cycled based on indentation. Required Color `defaultFrom:"theme.base.danger"` // used on the trailing "-required-" string }
ThemeExplain holds colors for the "kubectl explain" output.
type ThemeOptions ¶
type ThemeOptions struct {
Flag Color `defaultFrom:"theme.base.secondary"` // e.g "--kubeconfig"
}
ThemeOptions holds colors for the "kubectl options" output.
type ThemeStatus ¶
type ThemeStatus struct { Success Color `defaultFrom:"theme.base.success"` // used in status keywords, e.g "Running", "Ready" Warning Color `defaultFrom:"theme.base.warning"` // used in status keywords, e.g "Terminating" Error Color `defaultFrom:"theme.base.danger"` // used in status keywords, e.g "Failed", "Unhealthy" }
ThemeStatus holds colors for status texts, used in for example the "kubectl get" status column
type ThemeStderr ¶
type ThemeStderr struct { Default Color `defaultFrom:"theme.base.info"` // default when no specific mapping is found for the output line Error Color `defaultFrom:"theme.base.danger"` // e.g when text contains "error" }
ThemeStderr holds generic colors for kubectl's stderr output.
type ThemeTable ¶
type ThemeTable struct { Header Color `defaultFrom:"theme.base.info"` // used on table headers Columns ColorSlice `defaultFromMany:"theme.base.info,theme.base.secondary"` // used on table columns when no other coloring applies such as status or duration coloring. The multiple colors are cycled based on column ID, from left to right. }
ThemeTable holds colors for table output
type ThemeVersion ¶
type ThemeVersion struct {
Key ColorSlice `defaultFrom:"theme.base.key"` // used on the key
}
ThemeVersion holds colors for the "kubectl version" output.