oh-my-posh/segment_kubectl.go
Travis Illig 5844faa54d feat: dotnet segment for .NET SDK display
New segment for .NET SDK version (or unsupported version) display.

Includes update for handling command execution errors so segments
can act differently based on exit codes. Using a custom error
type to make it testable rather than passing the OS error directly
to the segment.
2020-10-16 11:39:01 -07:00

25 lines
452 B
Go

package main
type kubectl struct {
props *properties
env environmentInfo
contextName string
}
func (k *kubectl) string() string {
return k.contextName
}
func (k *kubectl) init(props *properties, env environmentInfo) {
k.props = props
k.env = env
}
func (k *kubectl) enabled() bool {
if !k.env.hasCommand("kubectl") {
return false
}
k.contextName, _ = k.env.runCommand("kubectl", "config", "current-context")
return true
}