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

Function New

pkg/cmd/factory/default.go:29–56  ·  view source on GitHub ↗
(appVersion string, invokingAgent string, cfgFunc func() (gh.Config, error), ios *iostreams.IOStreams, executablePath string, telemetryDisabler ghtelemetry.Disabler)

Source from the content-addressed store, hash-verified

27var ssoURLRE = regexp.MustCompile(`\burl=([^;]+)`)
28
29func New(appVersion string, invokingAgent string, cfgFunc func() (gh.Config, error), ios *iostreams.IOStreams, executablePath string, telemetryDisabler ghtelemetry.Disabler) *cmdutil.Factory {
30 // Inject the OAuth token refresher into the AuthConfig so refreshable credentials can be renewed during ordinary
31 // commands. It is wrapped around cfgFunc before anything else so every consumer resolves the same refresher-aware
32 // configuration.
33 cfgFunc = configWithTokenRefresher(cfgFunc, tokenRefresherHttpClientFunc(ios, appVersion, invokingAgent, telemetryDisabler))
34
35 f := &cmdutil.Factory{
36 AppVersion: appVersion,
37 InvokingAgent: invokingAgent,
38 Config: cfgFunc,
39 ExecutablePath: executablePath,
40 }
41
42 f.IOStreams = ios
43 f.TelemetryDisabler = telemetryDisabler
44 f.HttpClient = HttpClientFunc(cfgFunc, ios, appVersion, invokingAgent, telemetryDisabler)
45 f.PlainHttpClient = plainHttpClientFunc(ios, appVersion, invokingAgent, telemetryDisabler)
46 f.ExternalHttpClient = externalHttpClientFunc(ios, appVersion)
47 f.GitClient = newGitClient(f) // Depends on IOStreams, and Executable
48 f.Remotes = remotesFunc(f) // Depends on Config, and GitClient
49 f.BaseRepo = BaseRepoFunc(f.Remotes)
50 f.Prompter = newPrompter(f) // Depends on Config and IOStreams
51 f.Browser = newBrowser(f) // Depends on Config, and IOStreams
52 f.ExtensionManager = extensionManager(f) // Depends on Config, HttpClient, and IOStreams
53 f.Branch = branchFunc(f) // Depends on GitClient
54
55 return f
56}
57
58// BaseRepoFunc requests a list of Remotes, and selects the first one.
59// Although Remotes is injected via the factory so it looks like the function might

Callers 1

MainFunction · 0.92

Calls 12

configWithTokenRefresherFunction · 0.85
HttpClientFuncFunction · 0.85
plainHttpClientFuncFunction · 0.85
externalHttpClientFuncFunction · 0.85
newGitClientFunction · 0.85
remotesFuncFunction · 0.85
BaseRepoFuncFunction · 0.85
newPrompterFunction · 0.85
newBrowserFunction · 0.85
extensionManagerFunction · 0.85
branchFuncFunction · 0.85

Tested by

no test coverage detected