MCPcopy
hub / github.com/cli/cli / listRun

Function listRun

pkg/cmd/repo/gitignore/list/list.go:44–71  ·  view source on GitHub ↗
(opts *ListOptions)

Source from the content-addressed store, hash-verified

42}
43
44func listRun(opts *ListOptions) error {
45 client, err := opts.HTTPClient()
46 if err != nil {
47 return err
48 }
49
50 cfg, err := opts.Config()
51 if err != nil {
52 return err
53 }
54
55 if err := opts.IO.StartPager(); err != nil {
56 fmt.Fprintf(opts.IO.ErrOut, "starting pager failed: %v\n", err)
57 }
58 defer opts.IO.StopPager()
59
60 hostname, _ := cfg.Authentication().DefaultHost()
61 gitIgnoreTemplates, err := api.RepoGitIgnoreTemplates(client, hostname)
62 if err != nil {
63 return err
64 }
65
66 if len(gitIgnoreTemplates) == 0 {
67 return cmdutil.NewNoResultsError("No gitignore templates found")
68 }
69
70 return renderGitIgnoreTemplatesTable(gitIgnoreTemplates, opts)
71}
72
73func renderGitIgnoreTemplatesTable(gitIgnoreTemplates []string, opts *ListOptions) error {
74 t := tableprinter.New(opts.IO, tableprinter.WithHeader("GITIGNORE"))

Callers 2

TestListRunFunction · 0.70
NewCmdListFunction · 0.70

Calls 8

RepoGitIgnoreTemplatesFunction · 0.92
NewNoResultsErrorFunction · 0.92
StartPagerMethod · 0.80
StopPagerMethod · 0.80
ConfigMethod · 0.65
DefaultHostMethod · 0.65
AuthenticationMethod · 0.65

Tested by 1

TestListRunFunction · 0.56