MCPcopy Create free account
hub / github.com/driangle/taskmd / applyShortcutFilters

Function applyShortcutFilters

apps/cli/internal/cli/filter.go:29–56  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

27// applyShortcutFilters expands shortcut flags into filter expressions and applies
28// all filters, scope, and phase filtering. Used by both list and graph commands.
29func 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.
59func matchesAllFilters(task *model.Task, filters []filterCriteria) bool {

Callers 2

runGraphFunction · 0.85
applyListFiltersAndSortFunction · 0.85

Calls 4

warnUnknownScopeFunction · 0.85
filterTasksByScopeFunction · 0.85
filterTasksByPhaseFunction · 0.85
applyFiltersFunction · 0.70

Tested by

no test coverage detected