fix(migrate): replace .Text with .Meaning

resolves #1697
This commit is contained in:
Jan De Dobbeleer 2022-02-05 09:41:41 +01:00 committed by Jan De Dobbeleer
parent 35aead22fc
commit 06291e168b
13 changed files with 23 additions and 11 deletions

View file

@ -127,6 +127,10 @@ func (segment *Segment) migrationOne(env environment.Environment) {
}
case EXIT:
template := segment.Properties.GetString(properties.SegmentTemplate, segment.writer.Template())
if strings.Contains(template, ".Text") {
template = strings.ReplaceAll(template, ".Text", ".Meaning")
segment.Properties[properties.SegmentTemplate] = template
}
alwaysNumeric := properties.Property("always_numeric")
if segment.Properties.GetBool(alwaysNumeric, false) {
delete(segment.Properties, alwaysNumeric)

View file

@ -239,6 +239,14 @@ func TestSegmentTemplateMigration(t *testing.T) {
"error_icon": "FAIL",
},
},
{
Case: "EXIT - .Text",
Expected: " {{ .Meaning }} ",
Type: EXIT,
Props: properties.Map{
"template": "{{ .Text }}",
},
},
{
Case: "BATTERY",
Expected: ` {{ if not .Error }}{{ $stateList := list "Discharging" "Full" }}{{ if has .State.String $stateList }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ end }}{{ .Error }} `,

View file

@ -63,7 +63,7 @@
"foreground": "#ffffff",
"powerline_symbol": "\ue0b0",
"properties": {
"template": " {{ .Text }} "
"template": " {{ .Meaning }} "
},
"style": "powerline",
"type": "exit"

View file

@ -32,7 +32,7 @@
{
"foreground": "#C94A16",
"properties": {
"template": "x{{ .Text }} "
"template": "x{{ .Meaning }} "
},
"style": "plain",
"type": "exit"

View file

@ -73,7 +73,7 @@
"foreground": "#ffffff",
"powerline_symbol": "\ue0b0",
"properties": {
"template": "<transparent> \uf12a</> {{ .Text }} "
"template": "<transparent> \uf12a</> {{ .Meaning }} "
},
"style": "powerline",
"type": "exit"

View file

@ -31,7 +31,7 @@
{
"foreground": "#ffffff",
"properties": {
"template": "<#CB4B16>[x</>{{ .Text }}<#CB4B16>]</>"
"template": "<#CB4B16>[x</>{{ .Meaning }}<#CB4B16>]</>"
},
"style": "plain",
"type": "exit"

View file

@ -43,7 +43,7 @@
{
"foreground": "#C94A16",
"properties": {
"template": "x{{ .Text }} "
"template": "x{{ .Meaning }} "
},
"style": "plain",
"type": "exit"

View file

@ -7,7 +7,7 @@
{
"foreground": "#ffffff",
"properties": {
"template": " {{ .Text }}"
"template": " {{ .Meaning }}"
},
"style": "plain",
"type": "exit"

View file

@ -71,7 +71,7 @@
{
"foreground": "#CB4B16",
"properties": {
"template": " {{ .Text }} "
"template": " {{ .Meaning }} "
},
"style": "plain",
"type": "exit"

View file

@ -90,7 +90,7 @@
"foreground": "#ffffff",
"leading_diamond": "<transparent,background>\ue0b0</>",
"properties": {
"template": "<transparent> \uf12a</> {{ .Text }} "
"template": "<transparent> \uf12a</> {{ .Meaning }} "
},
"style": "diamond",
"trailing_diamond": "\ue0b0",

View file

@ -50,7 +50,7 @@
{
"foreground": "#d8dee9",
"properties": {
"template": "<#5e81ac>[x</>{{ .Text }}<#5e81ac>]</>"
"template": "<#5e81ac>[x</>{{ .Meaning }}<#5e81ac>]</>"
},
"style": "plain",
"type": "exit"

View file

@ -174,7 +174,7 @@
"powerline_symbol": "\ue0b2",
"properties": {
"always_enabled": true,
"template": " {{ if gt .Code 0 }}{{ .Text }}{{ else }}\u2714{{ end }} "
"template": " {{ if gt .Code 0 }}{{ .Meaning }}{{ else }}\u2714{{ end }} "
},
"style": "powerline",
"type": "exit"

View file

@ -7,7 +7,7 @@
{
"foreground": "#CB4B16",
"properties": {
"template": " {{ .Text }} "
"template": " {{ .Meaning }} "
},
"style": "plain",
"type": "exit"