mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-22 00:21:11 -08:00
refactor: remove if/else statements
This commit is contained in:
parent
3bc476488a
commit
701cd499df
|
@ -153,11 +153,10 @@ func (u *Umbraco) TryFindLegacyUmbraco(configPath string) bool {
|
||||||
for _, appSetting := range webConfigAppSettings.AppSettings {
|
for _, appSetting := range webConfigAppSettings.AppSettings {
|
||||||
if strings.EqualFold(appSetting.Key, "umbraco.core.configurationstatus") || strings.EqualFold(appSetting.Key, "umbracoConfigurationStatus") {
|
if strings.EqualFold(appSetting.Key, "umbraco.core.configurationstatus") || strings.EqualFold(appSetting.Key, "umbracoConfigurationStatus") {
|
||||||
u.Modern = false
|
u.Modern = false
|
||||||
|
u.Version = appSetting.Value
|
||||||
|
|
||||||
if len(appSetting.Value) == 0 {
|
if len(u.Version) == 0 {
|
||||||
u.Version = UNKNOWN
|
u.Version = UNKNOWN
|
||||||
} else {
|
|
||||||
u.Version = appSetting.Value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -222,16 +222,18 @@ func (t *Text) cleanTemplate() {
|
||||||
result += string(char)
|
result += string(char)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// end of a variable, needs to be appended
|
|
||||||
if !isKnownVariable(property) { //nolint: gocritic
|
switch {
|
||||||
|
case !isKnownVariable(property):
|
||||||
|
// end of a variable, needs to be appended
|
||||||
result += ".Data" + property
|
result += ".Data" + property
|
||||||
} else if strings.HasPrefix(property, ".Segments") && !strings.HasSuffix(property, ".Contains") {
|
case strings.HasPrefix(property, ".Segments") && !strings.HasSuffix(property, ".Contains"):
|
||||||
// as we can't provide a clean way to access the list
|
// as we can't provide a clean way to access the list
|
||||||
// of segments, we need to replace the property with
|
// of segments, we need to replace the property with
|
||||||
// the list of segments so they can be accessed directly
|
// the list of segments so they can be accessed directly
|
||||||
property = strings.Replace(property, ".Segments", ".Segments.ToSimple", 1)
|
property = strings.Replace(property, ".Segments", ".Segments.ToSimple", 1)
|
||||||
result += property
|
result += property
|
||||||
} else {
|
default:
|
||||||
// check if we have the same property in Data
|
// check if we have the same property in Data
|
||||||
// and replace it with the Data property so it
|
// and replace it with the Data property so it
|
||||||
// can take precedence
|
// can take precedence
|
||||||
|
@ -242,6 +244,7 @@ func (t *Text) cleanTemplate() {
|
||||||
property = strings.TrimPrefix(property, globalRef)
|
property = strings.TrimPrefix(property, globalRef)
|
||||||
result += property
|
result += property
|
||||||
}
|
}
|
||||||
|
|
||||||
property = ""
|
property = ""
|
||||||
result += string(char)
|
result += string(char)
|
||||||
inProperty = false
|
inProperty = false
|
||||||
|
|
|
@ -428,17 +428,19 @@ func writeSegmentColors() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if fg.IsTransparent() && len(BackgroundColor) != 0 { //nolint: gocritic
|
switch {
|
||||||
|
case fg.IsTransparent() && len(BackgroundColor) != 0:
|
||||||
background := getAnsiFromColorString(BackgroundColor, false)
|
background := getAnsiFromColorString(BackgroundColor, false)
|
||||||
writeEscapedAnsiString(fmt.Sprintf(colorise, background))
|
writeEscapedAnsiString(fmt.Sprintf(colorise, background))
|
||||||
writeEscapedAnsiString(fmt.Sprintf(colorise, bg.ToForeground()))
|
writeEscapedAnsiString(fmt.Sprintf(colorise, bg.ToForeground()))
|
||||||
} else if fg.IsTransparent() && !bg.IsEmpty() {
|
case fg.IsTransparent() && !bg.IsEmpty():
|
||||||
isTransparent = true
|
isTransparent = true
|
||||||
writeEscapedAnsiString(fmt.Sprintf(transparentStart, bg))
|
writeEscapedAnsiString(fmt.Sprintf(transparentStart, bg))
|
||||||
} else {
|
default:
|
||||||
if !bg.IsEmpty() && !bg.IsTransparent() {
|
if !bg.IsEmpty() && !bg.IsTransparent() {
|
||||||
writeEscapedAnsiString(fmt.Sprintf(colorise, bg))
|
writeEscapedAnsiString(fmt.Sprintf(colorise, bg))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !fg.IsEmpty() {
|
if !fg.IsEmpty() {
|
||||||
writeEscapedAnsiString(fmt.Sprintf(colorise, fg))
|
writeEscapedAnsiString(fmt.Sprintf(colorise, fg))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue