()
| 145 | } |
| 146 | |
| 147 | func runNextAllProjects() error { |
| 148 | expandNextShortcutFilters() |
| 149 | |
| 150 | allRecs, err := collectAllProjectRecs() |
| 151 | if err != nil { |
| 152 | return err |
| 153 | } |
| 154 | |
| 155 | // Sort by score descending, re-assign ranks |
| 156 | sort.Slice(allRecs, func(i, j int) bool { |
| 157 | return allRecs[i].Score > allRecs[j].Score |
| 158 | }) |
| 159 | if nextLimit > 0 && nextLimit < len(allRecs) { |
| 160 | allRecs = allRecs[:nextLimit] |
| 161 | } |
| 162 | for i := range allRecs { |
| 163 | allRecs[i].Rank = i + 1 |
| 164 | } |
| 165 | |
| 166 | switch nextFormat { |
| 167 | case "json": |
| 168 | return WriteJSON(os.Stdout, allRecs) |
| 169 | case "yaml": |
| 170 | return WriteYAML(os.Stdout, allRecs) |
| 171 | case "table": |
| 172 | return outputNextAllProjectsTable(allRecs) |
| 173 | default: |
| 174 | return ValidateFormat(nextFormat, []string{"table", "json", "yaml"}) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | // collectAllProjectRecs gathers recommendations from every registered project. |
| 179 | func collectAllProjectRecs() ([]ProjectRecommendation, error) { |
no test coverage detected