MCPcopy
hub / github.com/cli/cli / SearchIssues

Function SearchIssues

pkg/cmd/search/shared/shared.go:58–97  ·  view source on GitHub ↗
(opts *IssuesOptions)

Source from the content-addressed store, hash-verified

56}
57
58func SearchIssues(opts *IssuesOptions) error {
59 io := opts.IO
60 if opts.WebMode {
61 url := opts.Searcher.URL(opts.Query)
62 if io.IsStdoutTTY() {
63 fmt.Fprintf(io.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(url))
64 }
65 return opts.Browser.Browse(url)
66 }
67 io.StartProgressIndicator()
68 result, err := opts.Searcher.Issues(opts.Query)
69 io.StopProgressIndicator()
70 if err != nil {
71 return err
72 }
73 if len(result.Items) == 0 && opts.Exporter == nil {
74 var msg string
75 switch opts.Entity {
76 case Both:
77 msg = "no issues or pull requests matched your search"
78 case Issues:
79 msg = "no issues matched your search"
80 case PullRequests:
81 msg = "no pull requests matched your search"
82 }
83 return cmdutil.NewNoResultsError(msg)
84 }
85
86 if err := io.StartPager(); err == nil {
87 defer io.StopPager()
88 } else {
89 fmt.Fprintf(io.ErrOut, "failed to start pager: %v\n", err)
90 }
91
92 if opts.Exporter != nil {
93 return opts.Exporter.Write(io, result.Items)
94 }
95
96 return displayIssueResults(io, opts.Now, opts.Entity, result)
97}
98
99func displayIssueResults(io *iostreams.IOStreams, now time.Time, et EntityType, results search.IssuesResult) error {
100 if now.IsZero() {

Callers 3

NewCmdPrsFunction · 0.92
NewCmdIssuesFunction · 0.92
TestSearchIssuesFunction · 0.85

Calls 12

DisplayURLFunction · 0.92
NewNoResultsErrorFunction · 0.92
displayIssueResultsFunction · 0.85
IsStdoutTTYMethod · 0.80
StartPagerMethod · 0.80
StopPagerMethod · 0.80
URLMethod · 0.65
BrowseMethod · 0.65
IssuesMethod · 0.65
StopProgressIndicatorMethod · 0.65
WriteMethod · 0.65

Tested by 1

TestSearchIssuesFunction · 0.68