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