(ptasks []*ProjectTask, columnsStr string)
| 186 | } |
| 187 | |
| 188 | func outputProjectTable(ptasks []*ProjectTask, columnsStr string) error { |
| 189 | if len(ptasks) == 0 { |
| 190 | fmt.Println("No tasks found") |
| 191 | return nil |
| 192 | } |
| 193 | |
| 194 | columns := strings.Split(columnsStr, ",") |
| 195 | for i, col := range columns { |
| 196 | columns[i] = strings.TrimSpace(col) |
| 197 | } |
| 198 | columns = injectProjectColumn(columns) |
| 199 | |
| 200 | r := getRenderer() |
| 201 | tw := NewTableWriter() |
| 202 | tw.AddHeader(columns) |
| 203 | tw.AddSeparator() |
| 204 | |
| 205 | for _, pt := range ptasks { |
| 206 | plain := make([]string, len(columns)) |
| 207 | colored := make([]string, len(columns)) |
| 208 | for i, col := range columns { |
| 209 | if col == "project" { |
| 210 | plain[i] = pt.ProjectID |
| 211 | colored[i] = pt.ProjectID |
| 212 | } else if col == "id" { |
| 213 | plain[i] = pt.QualifiedID() |
| 214 | colored[i] = formatTaskID(pt.QualifiedID(), r) |
| 215 | } else { |
| 216 | plain[i] = getColumnValue(pt.Task, col) |
| 217 | colored[i] = colorizeColumn(pt.Task, col, r) |
| 218 | } |
| 219 | } |
| 220 | tw.AddRow(plain, colored) |
| 221 | } |
| 222 | |
| 223 | tw.Flush(os.Stdout) |
| 224 | return nil |
| 225 | } |
| 226 | |
| 227 | // applyListFiltersAndSort applies all list filters, sorting, and limit. |
| 228 | func applyListFiltersAndSort(tasks []*model.Task) ([]*model.Task, error) { |
no test coverage detected