MCPcopy Index your code
hub / github.com/cli/cli / NewFromString

Function NewFromString

internal/config/stub.go:20–98  ·  view source on GitHub ↗
(cfgStr string)

Source from the content-addressed store, hash-verified

18}
19
20func NewFromString(cfgStr string) *ghmock.ConfigMock {
21 c := ghConfig.ReadFromString(cfgStr)
22 cfg := cfg{c}
23 mock := &ghmock.ConfigMock{}
24 mock.GetOrDefaultFunc = func(host, key string) o.Option[gh.ConfigEntry] {
25 return cfg.GetOrDefault(host, key)
26 }
27 mock.SetFunc = func(host, key, value string) {
28 cfg.Set(host, key, value)
29 }
30 mock.WriteFunc = func() error {
31 return cfg.Write()
32 }
33 mock.MigrateFunc = func(m gh.Migration) error {
34 return cfg.Migrate(m)
35 }
36 mock.AliasesFunc = func() gh.AliasConfig {
37 return &AliasConfig{cfg: c}
38 }
39 mock.AuthenticationFunc = func() gh.AuthConfig {
40 return &AuthConfig{
41 cfg: c,
42 defaultHostOverride: func() (string, string) {
43 return "github.com", "default"
44 },
45 hostsOverride: func() []string {
46 keys, _ := c.Keys([]string{hostsKey})
47 return keys
48 },
49 tokenOverride: func(hostname string) (string, string) {
50 token, _ := c.Get([]string{hostsKey, hostname, oauthTokenKey})
51 return token, oauthTokenKey
52 },
53 }
54 }
55 mock.AccessibleColorsFunc = func(hostname string) gh.ConfigEntry {
56 return cfg.AccessibleColors(hostname)
57 }
58 mock.AccessiblePrompterFunc = func(hostname string) gh.ConfigEntry {
59 return cfg.AccessiblePrompter(hostname)
60 }
61 mock.BrowserFunc = func(hostname string) gh.ConfigEntry {
62 return cfg.Browser(hostname)
63 }
64 mock.TelemetryFunc = func() gh.ConfigEntry {
65 return cfg.Telemetry()
66 }
67 mock.ColorLabelsFunc = func(hostname string) gh.ConfigEntry {
68 return cfg.ColorLabels(hostname)
69 }
70 mock.EditorFunc = func(hostname string) gh.ConfigEntry {
71 return cfg.Editor(hostname)
72 }
73 mock.GitProtocolFunc = func(hostname string) gh.ConfigEntry {
74 return cfg.GitProtocol(hostname)
75 }
76 mock.HTTPUnixSocketFunc = func(hostname string) gh.ConfigEntry {
77 return cfg.HTTPUnixSocket(hostname)

Callers 15

defaultConfigFunction · 0.92
TestNewCmdCreateFunction · 0.92
TestImportRunFunction · 0.92
TestDeleteRunFunction · 0.92
TestAliasListFunction · 0.92
TestNewCmdCreateFunction · 0.92
Test_mightBeGHESUserFunction · 0.92
pagerConfigFunction · 0.92
disablePromptConfigFunction · 0.92
disableSpinnersConfigFunction · 0.92

Calls 15

GetOrDefaultMethod · 0.95
SetMethod · 0.95
WriteMethod · 0.95
MigrateMethod · 0.95
AccessibleColorsMethod · 0.95
AccessiblePrompterMethod · 0.95
BrowserMethod · 0.95
TelemetryMethod · 0.95
ColorLabelsMethod · 0.95
EditorMethod · 0.95
GitProtocolMethod · 0.95
HTTPUnixSocketMethod · 0.95

Tested by 15

defaultConfigFunction · 0.74
TestNewCmdCreateFunction · 0.74
TestImportRunFunction · 0.74
TestDeleteRunFunction · 0.74
TestAliasListFunction · 0.74
TestNewCmdCreateFunction · 0.74
Test_mightBeGHESUserFunction · 0.74
pagerConfigFunction · 0.74
disablePromptConfigFunction · 0.74
disableSpinnersConfigFunction · 0.74