mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-24 17:42:15 -08:00
32 lines
624 B
Go
32 lines
624 B
Go
package segments
|
|
|
|
import (
|
|
"oh-my-posh/environment"
|
|
"oh-my-posh/properties"
|
|
)
|
|
|
|
type Terraform struct {
|
|
props properties.Properties
|
|
env environment.Environment
|
|
|
|
WorkspaceName string
|
|
}
|
|
|
|
func (tf *Terraform) Template() string {
|
|
return "{{ .WorkspaceName }}"
|
|
}
|
|
|
|
func (tf *Terraform) Init(props properties.Properties, env environment.Environment) {
|
|
tf.props = props
|
|
tf.env = env
|
|
}
|
|
|
|
func (tf *Terraform) Enabled() bool {
|
|
cmd := "terraform"
|
|
if !tf.env.HasCommand(cmd) || !tf.env.HasFolder(tf.env.Pwd()+"/.terraform") {
|
|
return false
|
|
}
|
|
tf.WorkspaceName, _ = tf.env.RunCommand(cmd, "workspace", "show")
|
|
return true
|
|
}
|