mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
fix(os): use correct Android platform name
This commit is contained in:
parent
9b011b45a8
commit
1f283051d2
|
@ -19,50 +19,6 @@ const (
|
||||||
Linux properties.Property = "linux"
|
Linux properties.Property = "linux"
|
||||||
// Windows the string/icon to use for windows
|
// Windows the string/icon to use for windows
|
||||||
Windows properties.Property = "windows"
|
Windows properties.Property = "windows"
|
||||||
// Alma the string/icon to use for Alma
|
|
||||||
Alma properties.Property = "alma"
|
|
||||||
// Alpine the string/icon to use for Alpine
|
|
||||||
Alpine properties.Property = "alpine"
|
|
||||||
// Aosc the string/icon to use for Aosc
|
|
||||||
Aosc properties.Property = "aosc"
|
|
||||||
// Arch the string/icon to use for Arch
|
|
||||||
Arch properties.Property = "arch"
|
|
||||||
// Centos the string/icon to use for Centos
|
|
||||||
Centos properties.Property = "centos"
|
|
||||||
// Coreos the string/icon to use for Coreos
|
|
||||||
Coreos properties.Property = "coreos"
|
|
||||||
// Debian the string/icon to use for Debian
|
|
||||||
Debian properties.Property = "debian"
|
|
||||||
// Devuan the string/icon to use for Devuan
|
|
||||||
Devuan properties.Property = "devuan"
|
|
||||||
// Raspbian the string/icon to use for Raspbian
|
|
||||||
Raspbian properties.Property = "raspbian"
|
|
||||||
// Elementary the string/icon to use for Elementary
|
|
||||||
Elementary properties.Property = "elementary"
|
|
||||||
// Fedora the string/icon to use for Fedora
|
|
||||||
Fedora properties.Property = "fedora"
|
|
||||||
// Gentoo the string/icon to use for Gentoo
|
|
||||||
Gentoo properties.Property = "gentoo"
|
|
||||||
// Mageia the string/icon to use for Mageia
|
|
||||||
Mageia properties.Property = "mageia"
|
|
||||||
// Manjaro the string/icon to use for Manjaro
|
|
||||||
Manjaro properties.Property = "manjaro"
|
|
||||||
// Mint the string/icon to use for Mint
|
|
||||||
Mint properties.Property = "mint"
|
|
||||||
// Nixos the string/icon to use for Nixos
|
|
||||||
Nixos properties.Property = "nixos"
|
|
||||||
// Opensuse the string/icon to use for Opensuse
|
|
||||||
Opensuse properties.Property = "opensuse"
|
|
||||||
// Redhat the string/icon to use for Redhat
|
|
||||||
Redhat properties.Property = "redhat"
|
|
||||||
// Rocky the string/icon to use for Rocky linux
|
|
||||||
Rocky properties.Property = "rocky"
|
|
||||||
// Sabayon the string/icon to use for Sabayon
|
|
||||||
Sabayon properties.Property = "sabayon"
|
|
||||||
// Slackware the string/icon to use for Slackware
|
|
||||||
Slackware properties.Property = "slackware"
|
|
||||||
// Ubuntu the string/icon to use for Ubuntu
|
|
||||||
Ubuntu properties.Property = "ubuntu"
|
|
||||||
// DisplayDistroName display the distro name or not
|
// DisplayDistroName display the distro name or not
|
||||||
DisplayDistroName properties.Property = "display_distro_name"
|
DisplayDistroName properties.Property = "display_distro_name"
|
||||||
)
|
)
|
||||||
|
@ -93,54 +49,42 @@ func (oi *Os) Enabled() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oi *Os) getDistroIcon(distro string) string {
|
func (oi *Os) getDistroIcon(distro string) string {
|
||||||
switch distro {
|
iconMap := map[string]string{
|
||||||
case "alma":
|
"alma": "\uF31D",
|
||||||
return oi.props.GetString(Alma, "\uF31D")
|
"alpine": "\uF300",
|
||||||
case "alpine":
|
"aosc": "\uF301",
|
||||||
return oi.props.GetString(Alpine, "\uF300")
|
"arch": "\uF303",
|
||||||
case "aosc":
|
"centos": "\uF304",
|
||||||
return oi.props.GetString(Aosc, "\uF301")
|
"coreos": "\uF305",
|
||||||
case "arch":
|
"debian": "\uF306",
|
||||||
return oi.props.GetString(Arch, "\uF303")
|
"devuan": "\uF307",
|
||||||
case "centos":
|
"raspbian": "\uF315",
|
||||||
return oi.props.GetString(Centos, "\uF304")
|
"elementary": "\uF309",
|
||||||
case "coreos":
|
"fedora": "\uF30a",
|
||||||
return oi.props.GetString(Coreos, "\uF305")
|
"gentoo": "\uF30d",
|
||||||
case "debian":
|
"mageia": "\uF310",
|
||||||
return oi.props.GetString(Debian, "\uF306")
|
"manjaro": "\uF312",
|
||||||
case "devuan":
|
"mint": "\uF30e",
|
||||||
return oi.props.GetString(Devuan, "\uF307")
|
"nixos": "\uF313",
|
||||||
case "raspbian":
|
"opensuse": "\uF314",
|
||||||
return oi.props.GetString(Raspbian, "\uF315")
|
"opensuse-tumbleweed": "\uF314",
|
||||||
case "elementary":
|
"redhat": "\uF316",
|
||||||
return oi.props.GetString(Elementary, "\uF309")
|
"rocky": "\uF32B",
|
||||||
case "fedora":
|
"sabayon": "\uF317",
|
||||||
return oi.props.GetString(Fedora, "\uF30a")
|
"slackware": "\uF319",
|
||||||
case "gentoo":
|
"ubuntu": "\uF31b",
|
||||||
return oi.props.GetString(Gentoo, "\uF30d")
|
"android": "\uf17b",
|
||||||
case "mageia":
|
|
||||||
return oi.props.GetString(Mageia, "\uF310")
|
|
||||||
case "manjaro":
|
|
||||||
return oi.props.GetString(Manjaro, "\uF312")
|
|
||||||
case "mint":
|
|
||||||
return oi.props.GetString(Mint, "\uF30e")
|
|
||||||
case "nixos":
|
|
||||||
return oi.props.GetString(Nixos, "\uF313")
|
|
||||||
case "opensuse", "opensuse-tumbleweed":
|
|
||||||
return oi.props.GetString(Opensuse, "\uF314")
|
|
||||||
case "redhat":
|
|
||||||
return oi.props.GetString(Redhat, "\uF316")
|
|
||||||
case "rocky":
|
|
||||||
return oi.props.GetString(Rocky, "\uF32B")
|
|
||||||
case "sabayon":
|
|
||||||
return oi.props.GetString(Sabayon, "\uF317")
|
|
||||||
case "slackware":
|
|
||||||
return oi.props.GetString(Slackware, "\uF319")
|
|
||||||
case "ubuntu":
|
|
||||||
return oi.props.GetString(Ubuntu, "\uF31b")
|
|
||||||
case "android":
|
|
||||||
return oi.props.GetString(Ubuntu, "\uf17b")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if icon, ok := iconMap[distro]; ok {
|
||||||
|
return oi.props.GetString(properties.Property(distro), icon)
|
||||||
|
}
|
||||||
|
|
||||||
|
icon := oi.props.GetString(properties.Property(distro), "")
|
||||||
|
if len(icon) > 0 {
|
||||||
|
return icon
|
||||||
|
}
|
||||||
|
|
||||||
return oi.props.GetString(Linux, "\uF17C")
|
return oi.props.GetString(Linux, "\uF17C")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ func TestOSInfo(t *testing.T) {
|
||||||
IsWSL bool
|
IsWSL bool
|
||||||
Platform string
|
Platform string
|
||||||
DisplayDistroName bool
|
DisplayDistroName bool
|
||||||
|
Icon string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
Case: "WSL debian - icon",
|
Case: "WSL debian - icon",
|
||||||
|
@ -62,6 +63,19 @@ func TestOSInfo(t *testing.T) {
|
||||||
ExpectedString: "unknown",
|
ExpectedString: "unknown",
|
||||||
GOOS: "unknown",
|
GOOS: "unknown",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Case: "crazy distro, specific icon",
|
||||||
|
ExpectedString: "crazy distro",
|
||||||
|
GOOS: "linux",
|
||||||
|
Platform: "crazy",
|
||||||
|
Icon: "crazy distro",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Case: "crazy distro, not mapped",
|
||||||
|
ExpectedString: "\uf17c",
|
||||||
|
GOOS: "linux",
|
||||||
|
Platform: "crazy",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
env := new(mock.MockedEnvironment)
|
env := new(mock.MockedEnvironment)
|
||||||
|
@ -71,14 +85,22 @@ func TestOSInfo(t *testing.T) {
|
||||||
Env: make(map[string]string),
|
Env: make(map[string]string),
|
||||||
WSL: tc.IsWSL,
|
WSL: tc.IsWSL,
|
||||||
})
|
})
|
||||||
osInfo := &Os{
|
|
||||||
env: env,
|
props := properties.Map{
|
||||||
props: properties.Map{
|
DisplayDistroName: tc.DisplayDistroName,
|
||||||
DisplayDistroName: tc.DisplayDistroName,
|
Windows: "windows",
|
||||||
Windows: "windows",
|
MacOS: "darwin",
|
||||||
MacOS: "darwin",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(tc.Icon) != 0 {
|
||||||
|
props[properties.Property(tc.Platform)] = tc.Icon
|
||||||
|
}
|
||||||
|
|
||||||
|
osInfo := &Os{
|
||||||
|
env: env,
|
||||||
|
props: props,
|
||||||
|
}
|
||||||
|
|
||||||
_ = osInfo.Enabled()
|
_ = osInfo.Enabled()
|
||||||
assert.Equal(t, tc.ExpectedString, renderTemplate(env, osInfo.Template(), osInfo), tc.Case)
|
assert.Equal(t, tc.ExpectedString, renderTemplate(env, osInfo.Template(), osInfo), tc.Case)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1705,6 +1705,12 @@
|
||||||
"title": "Alma Icon",
|
"title": "Alma Icon",
|
||||||
"description": "The icon to use for Alma",
|
"description": "The icon to use for Alma",
|
||||||
"default": "\uF31D"
|
"default": "\uF31D"
|
||||||
|
},
|
||||||
|
"android": {
|
||||||
|
"type": "string",
|
||||||
|
"title": "Android Icon",
|
||||||
|
"description": "The icon to use for Alma",
|
||||||
|
"default": "\uf17b"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue