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

Function listRun

pkg/cmd/gist/list/list.go:112–151  ·  view source on GitHub ↗
(opts *ListOptions)

Source from the content-addressed store, hash-verified

110}
111
112func listRun(opts *ListOptions) error {
113 client, err := opts.HttpClient()
114 if err != nil {
115 return err
116 }
117
118 cfg, err := opts.Config()
119 if err != nil {
120 return err
121 }
122
123 host, _ := cfg.Authentication().DefaultHost()
124
125 // Filtering can take a while so start the progress indicator. StopProgressIndicator will no-op if not running.
126 if opts.Filter != nil {
127 opts.IO.StartProgressIndicator()
128 }
129 gists, err := shared.ListGists(client, host, opts.Limit, opts.Filter, opts.IncludeContent, opts.Visibility)
130 opts.IO.StopProgressIndicator()
131
132 if err != nil {
133 return err
134 }
135
136 if len(gists) == 0 {
137 return cmdutil.NewNoResultsError("no gists found")
138 }
139
140 if err := opts.IO.StartPager(); err == nil {
141 defer opts.IO.StopPager()
142 } else {
143 fmt.Fprintf(opts.IO.ErrOut, "failed to start pager: %v\n", err)
144 }
145
146 if opts.Filter != nil && opts.IncludeContent {
147 return printContent(opts.IO, gists, opts.Filter)
148 }
149
150 return printTable(opts.IO, gists, opts.Filter)
151}
152
153func printTable(io *iostreams.IOStreams, gists []shared.Gist, filter *regexp.Regexp) error {
154 cs := io.ColorScheme()

Callers 2

Test_listRunFunction · 0.70
NewCmdListFunction · 0.70

Calls 11

ListGistsFunction · 0.92
NewNoResultsErrorFunction · 0.92
printContentFunction · 0.85
StartPagerMethod · 0.80
StopPagerMethod · 0.80
printTableFunction · 0.70
ConfigMethod · 0.65
DefaultHostMethod · 0.65
AuthenticationMethod · 0.65
StopProgressIndicatorMethod · 0.65

Tested by 1

Test_listRunFunction · 0.56