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

Method GetOrDefault

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

Source from the content-addressed store, hash-verified

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

Callers 13

NewMockConfigFromStringFunction · 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