| 132 | } |
| 133 | |
| 134 | func reposRun(opts *ReposOptions) error { |
| 135 | io := opts.IO |
| 136 | if opts.WebMode { |
| 137 | url := opts.Searcher.URL(opts.Query) |
| 138 | if io.IsStdoutTTY() { |
| 139 | fmt.Fprintf(io.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(url)) |
| 140 | } |
| 141 | return opts.Browser.Browse(url) |
| 142 | } |
| 143 | io.StartProgressIndicator() |
| 144 | result, err := opts.Searcher.Repositories(opts.Query) |
| 145 | io.StopProgressIndicator() |
| 146 | if err != nil { |
| 147 | return err |
| 148 | } |
| 149 | if len(result.Items) == 0 && opts.Exporter == nil { |
| 150 | return cmdutil.NewNoResultsError("no repositories matched your search") |
| 151 | } |
| 152 | if err := io.StartPager(); err == nil { |
| 153 | defer io.StopPager() |
| 154 | } else { |
| 155 | fmt.Fprintf(io.ErrOut, "failed to start pager: %v\n", err) |
| 156 | } |
| 157 | if opts.Exporter != nil { |
| 158 | return opts.Exporter.Write(io, result.Items) |
| 159 | } |
| 160 | |
| 161 | return displayResults(io, opts.Now, result) |
| 162 | } |
| 163 | |
| 164 | func displayResults(io *iostreams.IOStreams, now time.Time, results search.RepositoriesResult) error { |
| 165 | if now.IsZero() { |