mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-13 20:27:28 -08:00
refactor: rename session properties for clarity
This commit is contained in:
parent
10e42db42c
commit
1a52aa9b04
|
@ -10,7 +10,7 @@
|
||||||
"foreground": "#ffffff",
|
"foreground": "#ffffff",
|
||||||
"properties": {
|
"properties": {
|
||||||
"user_info_separator": "",
|
"user_info_separator": "",
|
||||||
"display_computer": false,
|
"display_host": false,
|
||||||
"prefix": "<#CB4B16>┏[</>",
|
"prefix": "<#CB4B16>┏[</>",
|
||||||
"postfix": "<#CB4B16>]</>"
|
"postfix": "<#CB4B16>]</>"
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"user_info_separator": " <#ffffff>in</> ",
|
"user_info_separator": " <#ffffff>in</> ",
|
||||||
"prefix": "<#0377C8># </>",
|
"prefix": "<#0377C8># </>",
|
||||||
"user_color": "#0377C8",
|
"user_color": "#0377C8",
|
||||||
"computer_color": "#4A9207"
|
"host_color": "#4A9207"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
"foreground": "#E36464",
|
"foreground": "#E36464",
|
||||||
"properties": {
|
"properties": {
|
||||||
"user_info_separator": "",
|
"user_info_separator": "",
|
||||||
"display_computer": false,
|
"display_host": false,
|
||||||
"prefix": "@"
|
"prefix": "@"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,11 +68,11 @@ func TestDefaultColorWithUnavailableProperty(t *testing.T) {
|
||||||
|
|
||||||
func TestGetBool(t *testing.T) {
|
func TestGetBool(t *testing.T) {
|
||||||
expected := true
|
expected := true
|
||||||
values := map[Property]interface{}{DisplayComputer: expected}
|
values := map[Property]interface{}{DisplayHost: expected}
|
||||||
properties := properties{
|
properties := properties{
|
||||||
values: values,
|
values: values,
|
||||||
}
|
}
|
||||||
value := properties.getBool(DisplayComputer, false)
|
value := properties.getBool(DisplayHost, false)
|
||||||
assert.True(t, value)
|
assert.True(t, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,15 +81,15 @@ func TestGetBoolPropertyNotInMap(t *testing.T) {
|
||||||
properties := properties{
|
properties := properties{
|
||||||
values: values,
|
values: values,
|
||||||
}
|
}
|
||||||
value := properties.getBool(DisplayComputer, false)
|
value := properties.getBool(DisplayHost, false)
|
||||||
assert.False(t, value)
|
assert.False(t, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetBoolInvalidProperty(t *testing.T) {
|
func TestGetBoolInvalidProperty(t *testing.T) {
|
||||||
values := map[Property]interface{}{DisplayComputer: "borked"}
|
values := map[Property]interface{}{DisplayHost: "borked"}
|
||||||
properties := properties{
|
properties := properties{
|
||||||
values: values,
|
values: values,
|
||||||
}
|
}
|
||||||
value := properties.getBool(DisplayComputer, false)
|
value := properties.getBool(DisplayHost, false)
|
||||||
assert.False(t, value)
|
assert.False(t, value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,10 @@ const (
|
||||||
UserInfoSeparator Property = "user_info_separator"
|
UserInfoSeparator Property = "user_info_separator"
|
||||||
//UserColor if set, is used to color the user name
|
//UserColor if set, is used to color the user name
|
||||||
UserColor Property = "user_color"
|
UserColor Property = "user_color"
|
||||||
//ComputerColor if set, is used to color the computer name
|
//HostColor if set, is used to color the computer name
|
||||||
ComputerColor Property = "computer_color"
|
HostColor Property = "host_color"
|
||||||
//DisplayComputer hides or show the computer name
|
//DisplayHost hides or show the computer name
|
||||||
DisplayComputer Property = "display_computer"
|
DisplayHost Property = "display_host"
|
||||||
//DisplayUser hides or shows the user name
|
//DisplayUser hides or shows the user name
|
||||||
DisplayUser Property = "display_user"
|
DisplayUser Property = "display_user"
|
||||||
)
|
)
|
||||||
|
@ -39,11 +39,11 @@ func (s *session) init(props *properties, env environmentInfo) {
|
||||||
func (s *session) getFormattedText() string {
|
func (s *session) getFormattedText() string {
|
||||||
username := s.getUserName()
|
username := s.getUserName()
|
||||||
computername := s.getComputerName()
|
computername := s.getComputerName()
|
||||||
return fmt.Sprintf("<%s>%s</>%s<%s>%s</>", s.props.getColor(UserColor, s.props.foreground), username, s.props.getString(UserInfoSeparator, "@"), s.props.getColor(ComputerColor, s.props.foreground), computername)
|
return fmt.Sprintf("<%s>%s</>%s<%s>%s</>", s.props.getColor(UserColor, s.props.foreground), username, s.props.getString(UserInfoSeparator, "@"), s.props.getColor(HostColor, s.props.foreground), computername)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) getComputerName() string {
|
func (s *session) getComputerName() string {
|
||||||
if !s.props.getBool(DisplayComputer, true) {
|
if !s.props.getBool(DisplayHost, true) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
computername, err := s.env.getHostName()
|
computername, err := s.env.getHostName()
|
||||||
|
|
Loading…
Reference in a new issue