feat(exit): add template properties

This commit is contained in:
Jan De Dobbeleer 2021-11-14 13:39:00 +01:00 committed by Jan De Dobbeleer
parent f5aeed466e
commit f850f3b805
49 changed files with 272 additions and 251 deletions

View file

@ -344,23 +344,36 @@ This means that for user Bill, who has a user account `Bill` on Windows and `bil
{ {
"type": "git", "type": "git",
"style": "powerline", "style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549", "foreground": "#193549",
"background": "#ffeb3b" "foreground_templates": [
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ffffff{{ end }}"
],
"background": "#2e9599",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#f36943{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#a8216b{{ end }}",
"{{ if gt .Ahead 0 }}#35b5ff{{ end }}",
"{{ if gt .Behind 0 }}#f89cfa{{ end }}"
],
"powerline_symbol": "\uE0B0",
"properties": {
"fetch_status": true,
"branch_max_length": 25,
"template": "{{ .HEAD }}{{ .BranchStatus }}"
}
}, },
{ {
"type": "exit", "type": "exit",
"style": "diamond", "style": "diamond",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#00897b", "background": "#00897b",
"background_templates": ["{{ if gt .Code 0 }}#e91e63{{ end }}"],
"leading_diamond": "", "leading_diamond": "",
"trailing_diamond": "\uE0B4", "trailing_diamond": "\uE0B4",
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"error_color": "#e91e63", "template": "\uE23A",
"color_background": true, "prefix": "<parentBackground>\uE0B0</> "
"prefix": "<#193549>\uE0B0 \uE23A</>"
} }
} }
] ]

View file

@ -16,26 +16,26 @@ Displays the last exit code or that the last command failed based on the configu
"style": "diamond", "style": "diamond",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#00897b", "background": "#00897b",
"background_templates": [
"{{ if gt .Code 0 }}#e91e63{{ end }}",
],
"leading_diamond": "", "leading_diamond": "",
"trailing_diamond": "\uE0B4", "trailing_diamond": "\uE0B4",
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"error_color": "#e91e63", "template": "\uE23A",
"color_background": true, "prefix": "<#193549>\uE0B0</> "
"prefix": "<#193549>\uE0B0</> \uE23A"
} }
} }
``` ```
## Properties ## Properties
- display_exit_code: `boolean` - show or hide the exit code - defaults to `true`
- always_enabled: `boolean` - always show the status - defaults to `false` - always_enabled: `boolean` - always show the status - defaults to `false`
- color_background: `boolean` - color the background or foreground when an error occurs - defaults to `false`
- error_color: `string` [color][colors] - color to use when an error occurred
- always_numeric: `boolean` - always display exit code as a number - defaults to `false`
- success_icon: `string` - displays when there's no error and `"always_enabled": true` - defaults to `""`
- error_icon: `string` - displays when there's an error - defaults to `""`
[colors]: /docs/config-colors [colors]: /docs/config-colors
## Template Properties
- `.Code`: `number` - the last known exit code
- `.Text`: `string` - the textual meaning linked to exit code (if applicable, otherwise identical to `.Code`)

View file

@ -6,6 +6,8 @@ import (
"strings" "strings"
) )
// GIT Segement
const ( const (
// DisplayStatus shows the status of the repository // DisplayStatus shows the status of the repository
DisplayStatus Property = "display_status" DisplayStatus Property = "display_status"
@ -15,7 +17,6 @@ const (
DisplayWorktreeCount Property = "display_worktree_count" DisplayWorktreeCount Property = "display_worktree_count"
// DisplayUpstreamIcon show or hide the upstream icon // DisplayUpstreamIcon show or hide the upstream icon
DisplayUpstreamIcon Property = "display_upstream_icon" DisplayUpstreamIcon Property = "display_upstream_icon"
// LocalWorkingIcon the icon to use as the local working area changes indicator // LocalWorkingIcon the icon to use as the local working area changes indicator
LocalWorkingIcon Property = "local_working_icon" LocalWorkingIcon Property = "local_working_icon"
// LocalStagingIcon the icon to use as the local staging area changes indicator // LocalStagingIcon the icon to use as the local staging area changes indicator
@ -52,7 +53,7 @@ func (g *git) getBool(property, legacyProperty Property) bool {
return g.props.getBool(property, false) return g.props.getBool(property, false)
} }
func (g *git) renderDeprecatedString(statusColorsEnabled bool) string { func (g *git) deprecatedString(statusColorsEnabled bool) string {
if statusColorsEnabled { if statusColorsEnabled {
g.SetStatusColor() g.SetStatusColor()
} }
@ -129,3 +130,39 @@ func (g *git) colorStatusString(prefix, status, color string) string {
} }
return fmt.Sprintf("<%s>%s %s</>", color, prefix, status) return fmt.Sprintf("<%s>%s %s</>", color, prefix, status)
} }
// EXIT Segment
const (
// DisplayExitCode shows or hides the error code
DisplayExitCode Property = "display_exit_code"
// ErrorColor specify a different foreground color for the error text when using always_show = true
ErrorColor Property = "error_color"
// AlwaysNumeric shows error codes as numbers
AlwaysNumeric Property = "always_numeric"
// SuccessIcon displays when there's no error and AlwaysEnabled = true
SuccessIcon Property = "success_icon"
// ErrorIcon displays when there's an error
ErrorIcon Property = "error_icon"
)
func (e *exit) deprecatedString() string {
colorBackground := e.props.getBool(ColorBackground, false)
if e.Code != 0 && !colorBackground {
e.props.foreground = e.props.getColor(ErrorColor, e.props.foreground)
}
if e.Code != 0 && colorBackground {
e.props.background = e.props.getColor(ErrorColor, e.props.background)
}
if e.Code == 0 {
return e.props.getString(SuccessIcon, "")
}
errorIcon := e.props.getString(ErrorIcon, "")
if !e.props.getBool(DisplayExitCode, true) {
return errorIcon
}
if e.props.getBool(AlwaysNumeric, false) {
return fmt.Sprintf("%s%d", errorIcon, e.Code)
}
return fmt.Sprintf("%s%s", errorIcon, e.Text)
}

View file

@ -6,6 +6,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
// GIT Segment
func TestGetStatusDetailStringDefault(t *testing.T) { func TestGetStatusDetailStringDefault(t *testing.T) {
expected := "icon +1" expected := "icon +1"
status := &GitStatus{ status := &GitStatus{
@ -257,3 +259,45 @@ func TestStatusColorsWithoutDisplayStatus(t *testing.T) {
g.string() g.string()
assert.Equal(t, expected, g.props.background) assert.Equal(t, expected, g.props.background)
} }
// EXIT Segement
func TestExitWriterDeprecatedString(t *testing.T) {
cases := []struct {
ExitCode int
Expected string
SuccessIcon string
ErrorIcon string
DisplayExitCode bool
AlwaysNumeric bool
}{
{ExitCode: 129, Expected: "SIGHUP", DisplayExitCode: true},
{ExitCode: 5001, Expected: "5001", DisplayExitCode: true},
{ExitCode: 147, Expected: "SIGSTOP", DisplayExitCode: true},
{ExitCode: 147, Expected: "", DisplayExitCode: false},
{ExitCode: 147, Expected: "147", DisplayExitCode: true, AlwaysNumeric: true},
{ExitCode: 0, Expected: "wooopie", SuccessIcon: "wooopie"},
{ExitCode: 129, Expected: "err SIGHUP", ErrorIcon: "err ", DisplayExitCode: true},
{ExitCode: 129, Expected: "err", ErrorIcon: "err", DisplayExitCode: false},
}
for _, tc := range cases {
env := new(MockedEnvironment)
env.On("lastErrorCode", nil).Return(tc.ExitCode)
props := &properties{
foreground: "#111111",
background: "#ffffff",
values: map[Property]interface{}{
SuccessIcon: tc.SuccessIcon,
ErrorIcon: tc.ErrorIcon,
DisplayExitCode: tc.DisplayExitCode,
AlwaysNumeric: tc.AlwaysNumeric,
},
}
e := &exit{
env: env,
props: props,
}
assert.Equal(t, tc.Expected, e.string())
}
}

View file

@ -1,24 +1,14 @@
package main package main
import "fmt" import "strconv"
type exit struct { type exit struct {
props *properties props *properties
env environmentInfo env environmentInfo
}
const ( Code int
// DisplayExitCode shows or hides the error code Text string
DisplayExitCode Property = "display_exit_code" }
// ErrorColor specify a different foreground color for the error text when using always_show = true
ErrorColor Property = "error_color"
// AlwaysNumeric shows error codes as numbers
AlwaysNumeric Property = "always_numeric"
// SuccessIcon displays when there's no error and AlwaysEnabled = true
SuccessIcon Property = "success_icon"
// ErrorIcon displays when there's an error
ErrorIcon Property = "error_icon"
)
func (e *exit) enabled() bool { func (e *exit) enabled() bool {
if e.props.getBool(AlwaysEnabled, false) { if e.props.getBool(AlwaysEnabled, false) {
@ -37,28 +27,26 @@ func (e *exit) init(props *properties, env environmentInfo) {
} }
func (e *exit) getFormattedText() string { func (e *exit) getFormattedText() string {
exitCode := e.getMeaningFromExitCode() e.Code = e.env.lastErrorCode()
colorBackground := e.props.getBool(ColorBackground, false) e.Text = e.getMeaningFromExitCode()
if e.env.lastErrorCode() != 0 && !colorBackground { segmentTemplate := e.props.getString(SegmentTemplate, "")
e.props.foreground = e.props.getColor(ErrorColor, e.props.foreground) if len(segmentTemplate) == 0 {
return e.deprecatedString()
} }
if e.env.lastErrorCode() != 0 && colorBackground { template := &textTemplate{
e.props.background = e.props.getColor(ErrorColor, e.props.background) Template: segmentTemplate,
Context: e,
Env: e.env,
} }
if e.env.lastErrorCode() == 0 { text, err := template.render()
return e.props.getString(SuccessIcon, "") if err != nil {
return err.Error()
} }
return fmt.Sprintf("%s%s", e.props.getString(ErrorIcon, ""), exitCode) return text
} }
func (e *exit) getMeaningFromExitCode() string { func (e *exit) getMeaningFromExitCode() string {
if !e.props.getBool(DisplayExitCode, true) { switch e.Code {
return ""
}
if e.props.getBool(AlwaysNumeric, false) {
return fmt.Sprintf("%d", e.env.lastErrorCode())
}
switch e.env.lastErrorCode() {
case 1: case 1:
return "ERROR" return "ERROR"
case 2: case 2:
@ -112,6 +100,6 @@ func (e *exit) getMeaningFromExitCode() string {
case 128 + 22: case 128 + 22:
return "SIGTTOU" return "SIGTTOU"
default: default:
return fmt.Sprintf("%d", e.env.lastErrorCode()) return strconv.Itoa(e.Code)
} }
} }

View file

@ -26,46 +26,6 @@ func TestExitWriterEnabled(t *testing.T) {
} }
} }
func TestExitWriterFormattedText(t *testing.T) {
cases := []struct {
ExitCode int
Expected string
SuccessIcon string
ErrorIcon string
DisplayExitCode bool
AlwaysNumeric bool
}{
{ExitCode: 129, Expected: "SIGHUP", DisplayExitCode: true},
{ExitCode: 5001, Expected: "5001", DisplayExitCode: true},
{ExitCode: 147, Expected: "SIGSTOP", DisplayExitCode: true},
{ExitCode: 147, Expected: "", DisplayExitCode: false},
{ExitCode: 147, Expected: "147", DisplayExitCode: true, AlwaysNumeric: true},
{ExitCode: 0, Expected: "wooopie", SuccessIcon: "wooopie"},
{ExitCode: 129, Expected: "err SIGHUP", ErrorIcon: "err ", DisplayExitCode: true},
{ExitCode: 129, Expected: "err", ErrorIcon: "err", DisplayExitCode: false},
}
for _, tc := range cases {
env := new(MockedEnvironment)
env.On("lastErrorCode", nil).Return(tc.ExitCode)
props := &properties{
foreground: "#111111",
background: "#ffffff",
values: map[Property]interface{}{
SuccessIcon: tc.SuccessIcon,
ErrorIcon: tc.ErrorIcon,
DisplayExitCode: tc.DisplayExitCode,
AlwaysNumeric: tc.AlwaysNumeric,
},
}
e := &exit{
env: env,
props: props,
}
assert.Equal(t, tc.Expected, e.getFormattedText())
}
}
func TestGetMeaningFromExitCode(t *testing.T) { func TestGetMeaningFromExitCode(t *testing.T) {
errorMap := make(map[int]string) errorMap := make(map[int]string)
errorMap[1] = "ERROR" errorMap[1] = "ERROR"
@ -97,26 +57,34 @@ func TestGetMeaningFromExitCode(t *testing.T) {
errorMap[151] = "151" errorMap[151] = "151"
errorMap[7000] = "7000" errorMap[7000] = "7000"
for exitcode, want := range errorMap { for exitcode, want := range errorMap {
env := new(MockedEnvironment) e := &exit{}
env.On("lastErrorCode", nil).Return(exitcode) e.Code = exitcode
e := &exit{
env: env,
}
assert.Equal(t, want, e.getMeaningFromExitCode()) assert.Equal(t, want, e.getMeaningFromExitCode())
} }
} }
func TestAlwaysNumericExitCode(t *testing.T) { func TestExitWriterTemplateString(t *testing.T) {
env := new(MockedEnvironment) cases := []struct {
env.On("lastErrorCode", nil).Return(1) Case string
props := &properties{ ExitCode int
values: map[Property]interface{}{ Expected string
AlwaysNumeric: true, Template string
}, }{
{Case: "Only code", ExitCode: 129, Expected: "129", Template: "{{ .Code }}"},
} }
e := &exit{
env: env, for _, tc := range cases {
props: props, env := new(MockedEnvironment)
env.On("lastErrorCode", nil).Return(tc.ExitCode)
props := &properties{
values: map[Property]interface{}{
SegmentTemplate: tc.Template,
},
}
e := &exit{
env: env,
props: props,
}
assert.Equal(t, tc.Expected, e.string(), tc.Case)
} }
assert.Equal(t, "1", e.getMeaningFromExitCode())
} }

View file

@ -206,7 +206,7 @@ func (g *git) string() string {
} }
// legacy render string if no template // legacy render string if no template
// remove this for 6.0 // remove this for 6.0
return g.renderDeprecatedString(statusColorsEnabled) return g.deprecatedString(statusColorsEnabled)
} }
func (g *git) templateString(segmentTemplate string) string { func (g *git) templateString(segmentTemplate string) string {

View file

@ -57,7 +57,10 @@
"style": "powerline", "style": "powerline",
"powerline_symbol": "\uE0B0", "powerline_symbol": "\uE0B0",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#ff8080" "background": "#ff8080",
"properties": {
"template": "{{ .Text }}"
}
} }
] ]
} }

View file

@ -33,7 +33,8 @@
"style": "plain", "style": "plain",
"foreground": "#C94A16", "foreground": "#C94A16",
"properties": { "properties": {
"prefix": "x" "template": "x{{ .Text }}",
"prefix": ""
} }
} }
] ]

View file

@ -81,7 +81,8 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#910000", "background": "#910000",
"properties": { "properties": {
"prefix": "<transparent> \uF12A</> " "prefix": "<transparent> \uF12A</> ",
"template": "{{ .Text }}"
} }
} }
] ]
@ -124,11 +125,11 @@
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#ffffff", "foreground": "#ffffff",
"foreground_templates": ["{{ if gt .Code 0 }}#ff0000{{ end }}"],
"properties": { "properties": {
"prefix": "\u276F", "template": "\u276F",
"always_enabled": true, "prefix": "",
"error_color": "#ff0000", "always_enabled": true
"display_exit_code": false
} }
} }
] ]

View file

@ -95,14 +95,12 @@
"style": "diamond", "style": "diamond",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#007800", "background": "#007800",
"leading_diamond": "<transparent, #007800>\uE0B0</>", "background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
"leading_diamond": "<transparent,background>\uE0B0</>",
"trailing_diamond": "\uE0b0", "trailing_diamond": "\uE0b0",
"properties": { "properties": {
"display_exit_code": false, "template": "\ufc8d",
"always_enabled": true, "always_enabled": true
"error_color": "#f1184c",
"color_background": true,
"prefix": " \ufc8d"
} }
} }
] ]

View file

@ -52,12 +52,10 @@
"trailing_diamond": "\uE0B4", "trailing_diamond": "\uE0B4",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#491515", "background": "#491515",
"background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
"properties": { "properties": {
"display_exit_code": false, "template": "\uF7d4",
"always_enabled": true, "always_enabled": true
"error_color": "#f1184c",
"color_background": true,
"prefix": " \uF7d4"
} }
} }
] ]

View file

@ -95,11 +95,9 @@
"powerline_symbol": "\uE0B4", "powerline_symbol": "\uE0B4",
"foreground": "#242424", "foreground": "#242424",
"background": "#33DD2D", "background": "#33DD2D",
"background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
"properties": { "properties": {
"display_exit_code": false, "template": "\uF7d4"
"color_background": true,
"error_color": "#f1184c",
"prefix": " \ufc8d"
} }
} }
] ]

View file

@ -40,6 +40,7 @@
"style": "plain", "style": "plain",
"foreground": "#ffffff", "foreground": "#ffffff",
"properties": { "properties": {
"template": "{{ .Text }}",
"prefix": "<#CB4B16>[x</>", "prefix": "<#CB4B16>[x</>",
"postfix": "<#CB4B16>]</>" "postfix": "<#CB4B16>]</>"
} }

View file

@ -44,7 +44,8 @@
"style": "plain", "style": "plain",
"foreground": "#C94A16", "foreground": "#C94A16",
"properties": { "properties": {
"prefix": "x" "template": "x{{ .Text }}",
"prefix": ""
} }
}, },
{ {

View file

@ -10,6 +10,7 @@
"style": "plain", "style": "plain",
"foreground": "#ffffff", "foreground": "#ffffff",
"properties": { "properties": {
"template": "{{ .Text }}",
"postfix": "" "postfix": ""
} }
}, },

View file

@ -75,14 +75,12 @@
"style": "diamond", "style": "diamond",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#2e9599", "background": "#2e9599",
"leading_diamond": "<transparent, #2e9599>\uE0B0</>", "background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
"leading_diamond": "<transparent,background>\uE0B0</>",
"trailing_diamond": "\uE0B4", "trailing_diamond": "\uE0B4",
"properties": { "properties": {
"display_exit_code": false, "template": "\uF7d4",
"always_enabled": true, "always_enabled": true
"error_color": "#f1184c",
"color_background": true,
"prefix": " \uFC0C"
} }
} }
] ]

View file

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

View file

@ -69,12 +69,10 @@
"powerline_symbol": "\uE0B0", "powerline_symbol": "\uE0B0",
"foreground": "#242424", "foreground": "#242424",
"background": "#33DD2D", "background": "#33DD2D",
"background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
"properties": { "properties": {
"display_exit_code": false, "template": "\ufc8d",
"always_enabled": true, "always_enabled": true
"color_background": true,
"error_color": "#f1184c",
"prefix": " \ufc8d"
} }
} }
] ]

View file

@ -162,15 +162,14 @@
"type": "exit", "type": "exit",
"style": "diamond", "style": "diamond",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#2e9599", "background": "#00897b",
"background_templates": ["{{ if gt .Code 0 }}#e91e63{{ end }}"],
"leading_diamond": "", "leading_diamond": "",
"trailing_diamond": "", "trailing_diamond": "\uE0B4",
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"error_color": "#f1184c", "template": "\uE23A",
"color_background": true, "prefix": "<parentBackground>\uE0B0</> "
"prefix": "<#83769c>\uE0B0</> "
} }
} }
] ]

View file

@ -92,8 +92,9 @@
{ {
"background": "#910000", "background": "#910000",
"foreground": "#ffffff", "foreground": "#ffffff",
"leading_diamond": "<transparent,#910000>\uE0B0</>", "leading_diamond": "<transparent,background>\uE0B0</>",
"properties": { "properties": {
"template": "{{ .Text }}",
"prefix": "<transparent> \uF12A</> " "prefix": "<transparent> \uF12A</> "
}, },
"style": "diamond", "style": "diamond",

View file

@ -45,14 +45,13 @@
"style": "diamond", "style": "diamond",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#4707a8", "background": "#4707a8",
"background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
"leading_diamond": "", "leading_diamond": "",
"trailing_diamond": "\uE0B4", "trailing_diamond": "\uE0B4",
"properties": { "properties": {
"display_exit_code": false, "template": " \uE23A",
"always_enabled": true, "always_enabled": true,
"error_color": "#f1184c", "prefix": "<transparent>\uE0B0</>"
"color_background": true,
"prefix": "<transparent>\uE0B0</> \uE23A"
} }
} }
] ]

View file

@ -99,13 +99,10 @@
"powerline_symbol": "\uE0B0", "powerline_symbol": "\uE0B0",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#4caf50", "background": "#4caf50",
"background_templates": [], "background_templates": ["{{ if gt .Code 0 }}red{{ end }}"],
"properties": { "properties": {
"always_enabled": true, "always_enabled": true,
"success_icon": "\uf469 \u2665 ", "template": "{{ if gt .Code 0 }}\uf525{{ else }}\uf469 \u2665{{ end }} "
"color_background": true,
"error_icon": "\uf525 ",
"error_color": "red"
} }
} }
] ]

View file

@ -48,13 +48,11 @@
{ {
"background": "#0095e9", "background": "#0095e9",
"foreground": "#ffffff", "foreground": "#ffffff",
"leading_diamond": "<transparent, #0095e9>\uE0B0</>", "background_templates": ["{{ if gt .Code 0 }}#ff0044{{ end }}"],
"leading_diamond": "<transparent,background>\uE0B0</>",
"properties": { "properties": {
"always_enabled": true, "always_enabled": true,
"color_background": true, "template": ""
"display_exit_code": false,
"error_color": "#ff0044",
"prefix": " "
}, },
"style": "diamond", "style": "diamond",
"trailing_diamond": "", "trailing_diamond": "",

View file

@ -40,8 +40,9 @@
"style": "plain", "style": "plain",
"foreground": "#DCB977", "foreground": "#DCB977",
"properties": { "properties": {
"prefix": "\uF119", "template": "\uF119",
"display_exit_code": false "prefix": " ",
"postfix": ""
} }
}, },
{ {

View file

@ -77,12 +77,10 @@
"powerline_symbol": "\uE0B0", "powerline_symbol": "\uE0B0",
"foreground": "#242424", "foreground": "#242424",
"background": "#33DD2D", "background": "#33DD2D",
"background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"color_background": true, "template": "\ufc8d"
"error_color": "#f1184c",
"prefix": " \ufc8d"
} }
} }
] ]

View file

@ -103,10 +103,8 @@
"style": "plain", "style": "plain",
"foreground": "#ffffff", "foreground": "#ffffff",
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"success_icon": "<#00ff00>\uF633</>", "template": "{{ if gt .Code 0 }}\uF659{{ else }}\uF633{{ end }}"
"error_icon": "<#ff0000>\uF659</>"
} }
}, },
{ {

View file

@ -107,11 +107,11 @@
"type": "exit", "type": "exit",
"style": "powerline", "style": "powerline",
"foreground": "lightGreen", "foreground": "lightGreen",
"foreground_templates": ["{{ if gt .Code 0 }}red{{ end }}"],
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"error_color": "red", "template": "\u279c",
"prefix": "\u279c" "prefix": ""
} }
} }
] ]

View file

@ -290,11 +290,11 @@
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#22da6e", "foreground": "#22da6e",
"foreground_templates": ["{{ if gt .Code 0 }}#ef5350{{ end }}"],
"properties": { "properties": {
"prefix": "\ue285\ue285", "template": "\ue285\ue285",
"display_exit_code": false, "prefix": "",
"always_enabled": true, "always_enabled": true
"error_color": "#ef5350"
} }
} }
] ]

View file

@ -73,9 +73,7 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#ff4040", "background": "#ff4040",
"properties": { "properties": {
"display_exit_code": false, "template": "\ue70f"
"always_enabled": false,
"prefix": " \ue70f"
} }
}, },
{ {

View file

@ -58,7 +58,7 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#ff8080", "background": "#ff8080",
"properties": { "properties": {
"prefix": " \uE20F" "template": "\uE20F"
} }
} }
] ]

View file

@ -39,8 +39,8 @@
"style": "plain", "style": "plain",
"foreground": "#DCB977", "foreground": "#DCB977",
"properties": { "properties": {
"prefix": "\uF119", "template": "\uF119",
"display_exit_code": false "prefix": " "
} }
} }
] ]

View file

@ -78,13 +78,12 @@
"style": "plain", "style": "plain",
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#2e9599", "background": "#2e9599",
"background_templates": ["{{ if gt .Code 0 }}#f1184c{{ end }}"],
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"error_color": "#f1184c", "template": " \uE23A ",
"color_background": true, "prefix": "<transparent>\uE0B0</>",
"prefix": "<transparent>\uE0B0</> \uE23A ", "postfix": "<background,transparent>\uE0B4</>"
"postfix": "<#2e9599,transparent>\uE0B4</>"
} }
} }
] ]

View file

@ -88,11 +88,11 @@
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#D4E157", "foreground": "#D4E157",
"foreground_templates": ["{{ if gt .Code 0 }}#FF5252{{ end }}"],
"properties": { "properties": {
"prefix": "\u276F", "template": "\u276F",
"always_enabled": true, "prefix": "",
"error_color": "#FF5252", "always_enabled": true
"display_exit_code": false
} }
} }
] ]

View file

@ -94,11 +94,11 @@
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#D4E157", "foreground": "#D4E157",
"foreground_templates": ["{{ if gt .Code 0 }}#FF5252{{ end }}"],
"properties": { "properties": {
"prefix": "\u276F", "template": "\u276F",
"always_enabled": true, "prefix": "",
"error_color": "#FF5252", "always_enabled": true
"display_exit_code": false
} }
} }
] ]

View file

@ -170,12 +170,11 @@
"invert_powerline": true, "invert_powerline": true,
"foreground": "#d3d7cf", "foreground": "#d3d7cf",
"background": "#000000", "background": "#000000",
"background_templates": ["{{ if gt .Code 0 }}#cc2222{{ end }}"],
"properties": { "properties": {
"prefix": " ",
"always_enabled": true, "always_enabled": true,
"display_exit_code": true, "template": "{{ if gt .Code 0 }}{{ .Text }}{{ else }}✔{{ end }}"
"error_color": "#cc2222",
"color_background": true,
"success_icon": "✔"
} }
}, },
{ {

View file

@ -52,7 +52,7 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#ff8080", "background": "#ff8080",
"properties": { "properties": {
"prefix": "\uE20F" "template": "\uE20F"
} }
} }
] ]

View file

@ -77,10 +77,10 @@
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#B48EAD", "foreground": "#B48EAD",
"foreground_templates": ["{{ if gt .Code 0 }}#BF616A{{ end }}"],
"properties": { "properties": {
"prefix": "\u276f", "template": "\u276f",
"display_exit_code": false, "prefix": "",
"error_color": "#BF616A",
"always_enabled": true "always_enabled": true
} }
} }

View file

@ -37,10 +37,11 @@
{ {
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#DCB977", "foreground": "#BF616A",
"properties": { "properties": {
"prefix": "\u2717", "template": "\u2717",
"display_exit_code": false "prefix": " ",
"postfix": ""
} }
} }
] ]

View file

@ -473,30 +473,14 @@
"properties": { "properties": {
"properties": { "properties": {
"properties": { "properties": {
"display_exit_code": {
"type": "boolean",
"title": "Display Exit Code",
"description": "Show or hide the exit code",
"default": true
},
"always_enabled": { "always_enabled": {
"type": "boolean", "type": "boolean",
"title": "Always Enabled", "title": "Always Enabled",
"description": "Always show the status", "description": "Always show the status",
"default": false "default": false
}, },
"color_background": { "template": {
"type": "boolean", "$ref": "#/definitions/template"
"title": "Color Background",
"description": "Color the background or foreground",
"default": false
},
"error_color": { "$ref": "#/definitions/color" },
"always_numeric": {
"type": "boolean",
"title": "Always Numeric",
"description": "Always display the exit code as a number",
"default": false
} }
} }
} }
@ -1610,6 +1594,9 @@
"properties": { "properties": {
"properties": { "properties": {
"properties": { "properties": {
"template": {
"$ref": "#/definitions/template"
},
"always_enabled": { "always_enabled": {
"type": "boolean", "type": "boolean",
"title": "Always Enabled", "title": "Always Enabled",

View file

@ -207,13 +207,10 @@
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#9FD356", "foreground": "#9FD356",
"foreground_templates": ["{{ if gt .Code 0 }}#E84855{{ end }}"],
"properties": { "properties": {
"display_exit_code": true,
"always_numeric": true,
"always_enabled": true, "always_enabled": true,
"error_color": "#E84855", "template": "\uf705 {{ if gt .Code 0 }}{{ .Code }}{{ end }}"
"color_background": false,
"prefix": " \uf705 "
} }
} }
] ]

View file

@ -203,13 +203,10 @@
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#9FD356", "foreground": "#9FD356",
"foreground_templates": ["{{ if gt .Code 0 }}#E84855{{ end }}"],
"properties": { "properties": {
"display_exit_code": true,
"always_numeric": true,
"always_enabled": true, "always_enabled": true,
"error_color": "#E84855", "template": "\uf705 {{ if gt .Code 0 }}{{ .Code }}{{ end }}"
"color_background": false,
"prefix": " \uf705 "
} }
} }
] ]

View file

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

View file

@ -48,8 +48,8 @@
"style": "plain", "style": "plain",
"foreground": "#C94A16", "foreground": "#C94A16",
"properties": { "properties": {
"prefix": "x", "prefix": "",
"display_exit_code": false "template": "x"
} }
} }
] ]

View file

@ -107,10 +107,7 @@
"foreground": "#ffffff", "foreground": "#ffffff",
"background": "#ff8080", "background": "#ff8080",
"properties": { "properties": {
"display_exit_code": false, "template": "error"
"prefix": " ",
"postfix": " ",
"error_icon": "error"
} }
} }
] ]

View file

@ -104,11 +104,11 @@
"type": "exit", "type": "exit",
"style": "powerline", "style": "powerline",
"foreground": "lightGreen", "foreground": "lightGreen",
"foreground_templates": ["{{ if gt .Code 0 }}red{{ end }}"],
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"error_color": "red", "template": "\u279c",
"prefix": "\u279c" "prefix": ""
} }
} }
] ]

View file

@ -44,10 +44,12 @@
{ {
"type": "exit", "type": "exit",
"style": "plain", "style": "plain",
"foreground": "#7FFFD4",
"foreground_templates": ["{{ if gt .Code 0 }}#E84855{{ end }}"],
"properties": { "properties": {
"display_exit_code": false,
"always_enabled": true, "always_enabled": true,
"prefix": "<#66CDAA>\u276F</><#76EEC6>\u276F</><#7FFFD4>\u276F</>" "template": "<#66CDAA>\u276F</><#76EEC6>\u276F</><foreground>\u276F</>",
"prefix": ""
} }
} }
] ]

View file

@ -80,7 +80,7 @@
"style": "plain", "style": "plain",
"foreground": "red", "foreground": "red",
"properties": { "properties": {
"prefix": " C:", "template": "C:{{ if gt .Code 0 }}{{ .Code }}{{ end }}",
"always_numeric": true "always_numeric": true
} }
} }

View file

@ -50,8 +50,7 @@
"style": "plain", "style": "plain",
"foreground": "#DCB977", "foreground": "#DCB977",
"properties": { "properties": {
"prefix": "\uF119", "template": "\uF119",
"display_exit_code": false,
"postfix": "" "postfix": ""
} }
} }