mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(az): allow color templates
This commit is contained in:
parent
2d25c59c00
commit
35e0a6d42c
|
@ -8,7 +8,15 @@ import (
|
||||||
type az struct {
|
type az struct {
|
||||||
props *properties
|
props *properties
|
||||||
env environmentInfo
|
env environmentInfo
|
||||||
AZ *AzureAccount
|
|
||||||
|
EnvironmentName string `json:"environmentName"`
|
||||||
|
HomeTenantID string `json:"homeTenantId"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
IsDefault bool `json:"isDefault"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
State string `json:"state"`
|
||||||
|
TenantID string `json:"tenantId"`
|
||||||
|
User *AzureUser `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -22,25 +30,14 @@ type AzureUser struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AzureAccount struct {
|
|
||||||
EnvironmentName string `json:"environmentName"`
|
|
||||||
HomeTenantID string `json:"homeTenantId"`
|
|
||||||
ID string `json:"id"`
|
|
||||||
IsDefault bool `json:"isDefault"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
State string `json:"state"`
|
|
||||||
TenantID string `json:"tenantId"`
|
|
||||||
User *AzureUser `json:"user"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *az) string() string {
|
func (a *az) string() string {
|
||||||
if a.AZ != nil && a.AZ.Name == updateMessage {
|
if a != nil && a.Name == updateMessage {
|
||||||
return updateMessage
|
return updateMessage
|
||||||
}
|
}
|
||||||
segmentTemplate := a.props.getString(SegmentTemplate, "{{.Name}}")
|
segmentTemplate := a.props.getString(SegmentTemplate, "{{.Name}}")
|
||||||
template := &textTemplate{
|
template := &textTemplate{
|
||||||
Template: segmentTemplate,
|
Template: segmentTemplate,
|
||||||
Context: a.AZ,
|
Context: a,
|
||||||
Env: a.env,
|
Env: a.env,
|
||||||
}
|
}
|
||||||
text, err := template.render()
|
text, err := template.render()
|
||||||
|
@ -73,13 +70,11 @@ func (a *az) getFromEnvVars() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
a.AZ = &AzureAccount{
|
a.EnvironmentName = environmentName
|
||||||
EnvironmentName: environmentName,
|
a.Name = accountName
|
||||||
Name: accountName,
|
a.ID = id
|
||||||
ID: id,
|
a.User = &AzureUser{
|
||||||
User: &AzureUser{
|
Name: userName,
|
||||||
Name: userName,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -99,13 +94,10 @@ func (a *az) getFromAzCli() bool {
|
||||||
if strings.Contains(output, updateConsentNeeded) {
|
if strings.Contains(output, updateConsentNeeded) {
|
||||||
a.props.foreground = updateForeground
|
a.props.foreground = updateForeground
|
||||||
a.props.background = updateBackground
|
a.props.background = updateBackground
|
||||||
a.AZ = &AzureAccount{
|
a.Name = updateMessage
|
||||||
Name: updateMessage,
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
a.AZ = &AzureAccount{}
|
err := json.Unmarshal([]byte(output), a)
|
||||||
err := json.Unmarshal([]byte(output), a.AZ)
|
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue