"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pkg/cmd/root/root.go" between
gh-cli-1.11.0.tar.gz and gh-cli-1.12.0.tar.gz

About: GitHub CLI is GitHub’s official command line tool.

root.go  (gh-cli-1.11.0):root.go  (gh-cli-1.12.0)
package root package root
import ( import (
"net/http" "net/http"
"github.com/MakeNowJust/heredoc" "github.com/MakeNowJust/heredoc"
"github.com/cli/cli/api"
"github.com/cli/cli/context"
"github.com/cli/cli/internal/ghrepo"
actionsCmd "github.com/cli/cli/pkg/cmd/actions" actionsCmd "github.com/cli/cli/pkg/cmd/actions"
aliasCmd "github.com/cli/cli/pkg/cmd/alias" aliasCmd "github.com/cli/cli/pkg/cmd/alias"
apiCmd "github.com/cli/cli/pkg/cmd/api" apiCmd "github.com/cli/cli/pkg/cmd/api"
authCmd "github.com/cli/cli/pkg/cmd/auth" authCmd "github.com/cli/cli/pkg/cmd/auth"
browseCmd "github.com/cli/cli/pkg/cmd/browse"
completionCmd "github.com/cli/cli/pkg/cmd/completion" completionCmd "github.com/cli/cli/pkg/cmd/completion"
configCmd "github.com/cli/cli/pkg/cmd/config" configCmd "github.com/cli/cli/pkg/cmd/config"
extensionsCmd "github.com/cli/cli/pkg/cmd/extensions" extensionsCmd "github.com/cli/cli/pkg/cmd/extensions"
"github.com/cli/cli/pkg/cmd/factory" "github.com/cli/cli/pkg/cmd/factory"
gistCmd "github.com/cli/cli/pkg/cmd/gist" gistCmd "github.com/cli/cli/pkg/cmd/gist"
issueCmd "github.com/cli/cli/pkg/cmd/issue" issueCmd "github.com/cli/cli/pkg/cmd/issue"
prCmd "github.com/cli/cli/pkg/cmd/pr" prCmd "github.com/cli/cli/pkg/cmd/pr"
releaseCmd "github.com/cli/cli/pkg/cmd/release" releaseCmd "github.com/cli/cli/pkg/cmd/release"
repoCmd "github.com/cli/cli/pkg/cmd/repo" repoCmd "github.com/cli/cli/pkg/cmd/repo"
creditsCmd "github.com/cli/cli/pkg/cmd/repo/credits" creditsCmd "github.com/cli/cli/pkg/cmd/repo/credits"
skipping to change at line 59 skipping to change at line 57
`), `),
"help:environment": heredoc.Doc(` "help:environment": heredoc.Doc(`
See 'gh help environment' for the list of support ed environment variables. See 'gh help environment' for the list of support ed environment variables.
`), `),
}, },
} }
cmd.SetOut(f.IOStreams.Out) cmd.SetOut(f.IOStreams.Out)
cmd.SetErr(f.IOStreams.ErrOut) cmd.SetErr(f.IOStreams.ErrOut)
cs := f.IOStreams.ColorScheme()
helpHelper := func(command *cobra.Command, args []string) {
rootHelpFunc(cs, command, args)
}
cmd.PersistentFlags().Bool("help", false, "Show help for command") cmd.PersistentFlags().Bool("help", false, "Show help for command")
cmd.SetHelpFunc(helpHelper) cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
rootHelpFunc(f, cmd, args)
})
cmd.SetUsageFunc(rootUsageFunc) cmd.SetUsageFunc(rootUsageFunc)
cmd.SetFlagErrorFunc(rootFlagErrorFunc) cmd.SetFlagErrorFunc(rootFlagErrorFunc)
formattedVersion := versionCmd.Format(version, buildDate) formattedVersion := versionCmd.Format(version, buildDate)
cmd.SetVersionTemplate(formattedVersion) cmd.SetVersionTemplate(formattedVersion)
cmd.Version = formattedVersion cmd.Version = formattedVersion
cmd.Flags().Bool("version", false, "Show gh version") cmd.Flags().Bool("version", false, "Show gh version")
// Child commands // Child commands
cmd.AddCommand(versionCmd.NewCmdVersion(f, version, buildDate)) cmd.AddCommand(versionCmd.NewCmdVersion(f, version, buildDate))
cmd.AddCommand(actionsCmd.NewCmdActions(f)) cmd.AddCommand(actionsCmd.NewCmdActions(f))
cmd.AddCommand(aliasCmd.NewCmdAlias(f)) cmd.AddCommand(aliasCmd.NewCmdAlias(f))
cmd.AddCommand(authCmd.NewCmdAuth(f)) cmd.AddCommand(authCmd.NewCmdAuth(f))
cmd.AddCommand(configCmd.NewCmdConfig(f)) cmd.AddCommand(configCmd.NewCmdConfig(f))
cmd.AddCommand(creditsCmd.NewCmdCredits(f, nil)) cmd.AddCommand(creditsCmd.NewCmdCredits(f, nil))
cmd.AddCommand(gistCmd.NewCmdGist(f)) cmd.AddCommand(gistCmd.NewCmdGist(f))
cmd.AddCommand(completionCmd.NewCmdCompletion(f.IOStreams)) cmd.AddCommand(completionCmd.NewCmdCompletion(f.IOStreams))
cmd.AddCommand(extensionsCmd.NewCmdExtensions(f.IOStreams)) cmd.AddCommand(extensionsCmd.NewCmdExtensions(f))
cmd.AddCommand(secretCmd.NewCmdSecret(f)) cmd.AddCommand(secretCmd.NewCmdSecret(f))
cmd.AddCommand(sshKeyCmd.NewCmdSSHKey(f)) cmd.AddCommand(sshKeyCmd.NewCmdSSHKey(f))
// the `api` command should not inherit any extra HTTP headers // the `api` command should not inherit any extra HTTP headers
bareHTTPCmdFactory := *f bareHTTPCmdFactory := *f
bareHTTPCmdFactory.HttpClient = bareHTTPClient(f, version) bareHTTPCmdFactory.HttpClient = bareHTTPClient(f, version)
cmd.AddCommand(apiCmd.NewCmdApi(&bareHTTPCmdFactory, nil)) cmd.AddCommand(apiCmd.NewCmdApi(&bareHTTPCmdFactory, nil))
// below here at the commands that require the "intelligent" BaseRepo res olver // below here at the commands that require the "intelligent" BaseRepo res olver
repoResolvingCmdFactory := *f repoResolvingCmdFactory := *f
repoResolvingCmdFactory.BaseRepo = resolvedBaseRepo(f) repoResolvingCmdFactory.BaseRepo = factory.SmartBaseRepoFunc(f)
cmd.AddCommand(browseCmd.NewCmdBrowse(&repoResolvingCmdFactory, nil))
cmd.AddCommand(prCmd.NewCmdPR(&repoResolvingCmdFactory)) cmd.AddCommand(prCmd.NewCmdPR(&repoResolvingCmdFactory))
cmd.AddCommand(issueCmd.NewCmdIssue(&repoResolvingCmdFactory)) cmd.AddCommand(issueCmd.NewCmdIssue(&repoResolvingCmdFactory))
cmd.AddCommand(releaseCmd.NewCmdRelease(&repoResolvingCmdFactory)) cmd.AddCommand(releaseCmd.NewCmdRelease(&repoResolvingCmdFactory))
cmd.AddCommand(repoCmd.NewCmdRepo(&repoResolvingCmdFactory)) cmd.AddCommand(repoCmd.NewCmdRepo(&repoResolvingCmdFactory))
cmd.AddCommand(runCmd.NewCmdRun(&repoResolvingCmdFactory)) cmd.AddCommand(runCmd.NewCmdRun(&repoResolvingCmdFactory))
cmd.AddCommand(workflowCmd.NewCmdWorkflow(&repoResolvingCmdFactory)) cmd.AddCommand(workflowCmd.NewCmdWorkflow(&repoResolvingCmdFactory))
// Help topics // Help topics
cmd.AddCommand(NewHelpTopic("environment")) cmd.AddCommand(NewHelpTopic("environment"))
cmd.AddCommand(NewHelpTopic("formatting")) cmd.AddCommand(NewHelpTopic("formatting"))
skipping to change at line 126 skipping to change at line 121
referenceCmd.Long = referenceLong(cmd) referenceCmd.Long = referenceLong(cmd)
return cmd return cmd
} }
func bareHTTPClient(f *cmdutil.Factory, version string) func() (*http.Client, er ror) { func bareHTTPClient(f *cmdutil.Factory, version string) func() (*http.Client, er ror) {
return func() (*http.Client, error) { return func() (*http.Client, error) {
cfg, err := f.Config() cfg, err := f.Config()
if err != nil { if err != nil {
return nil, err return nil, err
} }
return factory.NewHTTPClient(f.IOStreams, cfg, version, false), n return factory.NewHTTPClient(f.IOStreams, cfg, version, false)
il
}
}
func resolvedBaseRepo(f *cmdutil.Factory) func() (ghrepo.Interface, error) {
return func() (ghrepo.Interface, error) {
httpClient, err := f.HttpClient()
if err != nil {
return nil, err
}
apiClient := api.NewClientFromHTTP(httpClient)
remotes, err := f.Remotes()
if err != nil {
return nil, err
}
repoContext, err := context.ResolveRemotesToRepos(remotes, apiCli
ent, "")
if err != nil {
return nil, err
}
baseRepo, err := repoContext.BaseRepo(f.IOStreams)
if err != nil {
return nil, err
}
return baseRepo, nil
} }
} }
 End of changes. 8 change blocks. 
41 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)