From 1a52aa9b0456d9de1dfd8da19908ea25a91b1256 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sat, 3 Oct 2020 20:11:44 +0200 Subject: [PATCH] refactor: rename session properties for clarity --- Themes/darkblood.json | 2 +- Themes/honukai.json | 2 +- Themes/zash.json | 2 +- properties_test.go | 10 +++++----- segment_session.go | 12 ++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Themes/darkblood.json b/Themes/darkblood.json index f7ddd31ffd3c..fa1f0dd06375 100644 --- a/Themes/darkblood.json +++ b/Themes/darkblood.json @@ -10,7 +10,7 @@ "foreground": "#ffffff", "properties": { "user_info_separator": "", - "display_computer": false, + "display_host": false, "prefix": "<#CB4B16>┏[", "postfix": "<#CB4B16>]" } diff --git a/Themes/honukai.json b/Themes/honukai.json index b29b89e7ac31..c59d5fdb29bb 100644 --- a/Themes/honukai.json +++ b/Themes/honukai.json @@ -12,7 +12,7 @@ "user_info_separator": " <#ffffff>in ", "prefix": "<#0377C8># ", "user_color": "#0377C8", - "computer_color": "#4A9207" + "host_color": "#4A9207" } }, { diff --git a/Themes/zash.json b/Themes/zash.json index eda1bff82433..6ed1d94d95c6 100644 --- a/Themes/zash.json +++ b/Themes/zash.json @@ -10,7 +10,7 @@ "foreground": "#E36464", "properties": { "user_info_separator": "", - "display_computer": false, + "display_host": false, "prefix": "@" } }, diff --git a/properties_test.go b/properties_test.go index 73883a724b17..888b204f4fe5 100644 --- a/properties_test.go +++ b/properties_test.go @@ -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) } diff --git a/segment_session.go b/segment_session.go index 66b889824eae..f7cc4f89402f 100755 --- a/segment_session.go +++ b/segment_session.go @@ -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()