MCPcopy
hub / github.com/cli/cli / GetOrDefault

Method GetOrDefault

internal/config/config.go:69–81  ·  view source on GitHub ↗
(hostname, key string)

Source from the content-addressed store, hash-verified

67}
68
69func (c *cfg) GetOrDefault(hostname, key string) o.Option[gh.ConfigEntry] {
70 if val := c.get(hostname, key); val.IsSome() {
71 // Map the Option[string] to Option[gh.ConfigEntry] with a source of ConfigUserProvided
72 return o.Map(val, toConfigEntry(gh.ConfigUserProvided))
73 }
74
75 if defaultVal := defaultFor(key); defaultVal.IsSome() {
76 // Map the Option[string] to Option[gh.ConfigEntry] with a source of ConfigDefaultProvided
77 return o.Map(defaultVal, toConfigEntry(gh.ConfigDefaultProvided))
78 }
79
80 return o.None[gh.ConfigEntry]()
81}
82
83// toConfigEntry is a helper function to convert a string value to a ConfigEntry with a given source.
84//

Callers 13

NewFromStringFunction · 0.95
AccessibleColorsMethod · 0.95
AccessiblePrompterMethod · 0.95
BrowserMethod · 0.95
ColorLabelsMethod · 0.95
EditorMethod · 0.95
GitProtocolMethod · 0.95
HTTPUnixSocketMethod · 0.95
PagerMethod · 0.95
PromptMethod · 0.95
PreferEditorPromptMethod · 0.95
SpinnerMethod · 0.95

Calls 5

getMethod · 0.95
toConfigEntryFunction · 0.85
defaultForFunction · 0.85
IsSomeMethod · 0.80
MapMethod · 0.80

Tested by

no test coverage detected