MCPcopy Create free account
hub / github.com/cli/cli / GetOrDefault

Method GetOrDefault

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

Source from the content-addressed store, hash-verified

76}
77
78func (c *cfg) GetOrDefault(hostname, key string) o.Option[gh.ConfigEntry] {
79 if val := c.get(hostname, key); val.IsSome() {
80 // Map the Option[string] to Option[gh.ConfigEntry] with a source of ConfigUserProvided
81 return o.Map(val, toConfigEntry(gh.ConfigUserProvided))
82 }
83
84 if defaultVal := defaultFor(key); defaultVal.IsSome() {
85 // Map the Option[string] to Option[gh.ConfigEntry] with a source of ConfigDefaultProvided
86 return o.Map(defaultVal, toConfigEntry(gh.ConfigDefaultProvided))
87 }
88
89 return o.None[gh.ConfigEntry]()
90}
91
92// toConfigEntry is a helper function to convert a string value to a ConfigEntry with a given source.
93//

Callers 15

NewMockConfigFromStringFunction · 0.95
AccessibleColorsMethod · 0.95
AccessiblePrompterMethod · 0.95
BrowserMethod · 0.95
ClipboardMethod · 0.95
ColorLabelsMethod · 0.95
EditorMethod · 0.95
GitProtocolMethod · 0.95
HTTPUnixSocketMethod · 0.95
PagerMethod · 0.95
PromptMethod · 0.95
PreferEditorPromptMethod · 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