mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-27 02:51:44 -08:00
feat(winreg): squashed commits
This commit is contained in:
parent
e3b6dbe91e
commit
18570c9cd0
|
@ -27,7 +27,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (n *new) enabled() bool {
|
func (n *new) enabled() bool {
|
||||||
true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *new) string() string {
|
func (n *new) string() string {
|
||||||
|
|
|
@ -32,11 +32,17 @@ func (wr *winreg) enabled() bool {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
wr.Value, err = wr.env.getWindowsRegistryKeyValue(registryPath, registryKey)
|
wr.Value, err = wr.env.getWindowsRegistryKeyValue(registryPath, registryKey)
|
||||||
if len(fallback) > 0 && (err != nil || len(wr.Value) == 0) {
|
|
||||||
wr.Value = fallback
|
if err != nil {
|
||||||
return true
|
if len(fallback) > 0 {
|
||||||
|
wr.Value = fallback
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
return err == nil && len(wr.Value) > 0
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wr *winreg) string() string {
|
func (wr *winreg) string() string {
|
||||||
|
|
|
@ -44,20 +44,20 @@ func TestRegQueryEnabled(t *testing.T) {
|
||||||
ExpectedValue: "cortana",
|
ExpectedValue: "cortana",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CaseDescription: "Fallback value on empty",
|
CaseDescription: "Empty string value (no error) should display empty string even in presence of fallback",
|
||||||
Path: "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion",
|
Path: "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion",
|
||||||
Key: "InstallTime",
|
Key: "InstallTime",
|
||||||
Output: "",
|
Output: "",
|
||||||
Fallback: "anaconda",
|
Fallback: "anaconda",
|
||||||
ExpectedSuccess: true,
|
ExpectedSuccess: true,
|
||||||
ExpectedValue: "anaconda",
|
ExpectedValue: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
CaseDescription: "Empty no fallback disabled",
|
CaseDescription: "Empty string value (no error) should display empty string",
|
||||||
Path: "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion",
|
Path: "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion",
|
||||||
Key: "InstallTime",
|
Key: "InstallTime",
|
||||||
Output: "",
|
Output: "",
|
||||||
ExpectedSuccess: false,
|
ExpectedSuccess: true,
|
||||||
ExpectedValue: "",
|
ExpectedValue: "",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@
|
||||||
"angular",
|
"angular",
|
||||||
"php",
|
"php",
|
||||||
"wifi",
|
"wifi",
|
||||||
"regquery"
|
"winreg"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"style": {
|
"style": {
|
||||||
|
@ -1725,6 +1725,32 @@
|
||||||
"title": "Registry Key",
|
"title": "Registry Key",
|
||||||
"description": "The key under he registry path to get (case insensitive). If left blank, will get the value of the (Default) key in the registry_path",
|
"description": "The key under he registry path to get (case insensitive). If left blank, will get the value of the (Default) key in the registry_path",
|
||||||
"default": ""
|
"default": ""
|
||||||
|
},
|
||||||
|
"query_fail_behaviour" : {
|
||||||
|
"type":"string",
|
||||||
|
"title": "Query failure behaviour",
|
||||||
|
"description": "What to do when the registry query fails",
|
||||||
|
"default":"hide_segment",
|
||||||
|
"enum": ["hide_segment", "display_fallback_string"]
|
||||||
|
},
|
||||||
|
"query_fail_fallback_string": {
|
||||||
|
"type": "string",
|
||||||
|
"title": "Query Failure fallback string",
|
||||||
|
"description": "In the event of a failure to get the requested key, this string will be displayed in the segment if 'query_fail_behaviour' is set to 'display_fallback_string'",
|
||||||
|
"default": ""
|
||||||
|
},
|
||||||
|
"query_fail_behaviour" : {
|
||||||
|
"type":"string",
|
||||||
|
"title": "Query failure behaviour",
|
||||||
|
"description": "What to do when the registry query fails",
|
||||||
|
"default":"hide_segment",
|
||||||
|
"enum": ["hide_segment", "display_fallback_string", "show_debug_info"]
|
||||||
|
},
|
||||||
|
"query_fail_fallback_string": {
|
||||||
|
"type": "string",
|
||||||
|
"title": "Query Failure fallback string",
|
||||||
|
"description": "In the event of a failure to get the requested key, this string will be displayed in the segment if 'query_fail_behaviour' is set to 'display_fallback_string'",
|
||||||
|
"default": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue