applyShortcutFilters expands shortcut flags into filter expressions and applies all filters, scope, and phase filtering. Used by both list and graph commands.
(tasks []*model.Task, s FilterShortcuts)
| 27 | // applyShortcutFilters expands shortcut flags into filter expressions and applies |
| 28 | // all filters, scope, and phase filtering. Used by both list and graph commands. |
| 29 | func applyShortcutFilters(tasks []*model.Task, s FilterShortcuts) ([]*model.Task, error) { |
| 30 | filters := append([]string{}, s.Filters...) |
| 31 | if s.Status != "" { |
| 32 | filters = append(filters, "status="+s.Status) |
| 33 | } |
| 34 | if s.Priority != "" { |
| 35 | filters = append(filters, "priority="+s.Priority) |
| 36 | } |
| 37 | |
| 38 | if len(filters) > 0 { |
| 39 | var err error |
| 40 | tasks, err = applyFilters(tasks, filters) |
| 41 | if err != nil { |
| 42 | return nil, fmt.Errorf("filter error: %w", err) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | if s.Scope != "" { |
| 47 | warnUnknownScope(s.Scope) |
| 48 | tasks = filterTasksByScope(tasks, s.Scope) |
| 49 | } |
| 50 | |
| 51 | if s.Phase != "" { |
| 52 | tasks = filterTasksByPhase(tasks, s.Phase) |
| 53 | } |
| 54 | |
| 55 | return tasks, nil |
| 56 | } |
| 57 | |
| 58 | // matchesAllFilters is kept for backward-compatible tests. |
| 59 | func matchesAllFilters(task *model.Task, filters []filterCriteria) bool { |
no test coverage detected