mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
5844faa54d
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.
25 lines
452 B
Go
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
|
|
}
|