nolint:gocognit,gocyclo,funlen // TODO: refactor to reduce complexity
(cmd *cobra.Command, args []string)
| 84 | |
| 85 | //nolint:gocognit,gocyclo,funlen // TODO: refactor to reduce complexity |
| 86 | func runGraph(cmd *cobra.Command, args []string) error { |
| 87 | flags := GetGlobalFlags() |
| 88 | |
| 89 | // Validate conflicting flags |
| 90 | if graphUpstream && graphDownstream { |
| 91 | return fmt.Errorf("cannot use both --upstream and --downstream") |
| 92 | } |
| 93 | |
| 94 | // --all overrides --exclude-status |
| 95 | if graphAll { |
| 96 | graphExcludeStatus = []string{} |
| 97 | } |
| 98 | |
| 99 | scanDir := ResolveScanDir(args) |
| 100 | |
| 101 | // Create scanner and scan for tasks |
| 102 | taskScanner := scanner.NewScanner(scanDir, flags.Verbose, flags.IgnoreDirs) |
| 103 | result, err := taskScanner.Scan() |
| 104 | if err != nil { |
| 105 | return fmt.Errorf("scan failed: %w", err) |
| 106 | } |
| 107 | |
| 108 | tasks := result.Tasks |
| 109 | |
| 110 | // Report any scan errors if verbose |
| 111 | if flags.Verbose && len(result.Errors) > 0 { |
| 112 | fmt.Fprintf(os.Stderr, "\nWarning: encountered %d errors during scan:\n", len(result.Errors)) |
| 113 | for _, scanErr := range result.Errors { |
| 114 | fmt.Fprintf(os.Stderr, " %s: %v\n", scanErr.FilePath, scanErr.Error) |
| 115 | } |
| 116 | fmt.Fprintln(os.Stderr) |
| 117 | } |
| 118 | |
| 119 | warnDuplicateIDs(tasks) |
| 120 | |
| 121 | filtered := false |
| 122 | |
| 123 | // Apply shortcut and generic filters |
| 124 | shortcuts := FilterShortcuts{ |
| 125 | Status: graphStatus, |
| 126 | Priority: graphPriority, |
| 127 | Phase: graphPhase, |
| 128 | Scope: graphScope, |
| 129 | Filters: graphFilters, |
| 130 | } |
| 131 | hasShortcutFilters := shortcuts.Status != "" || shortcuts.Priority != "" || |
| 132 | shortcuts.Phase != "" || shortcuts.Scope != "" || len(shortcuts.Filters) > 0 |
| 133 | if hasShortcutFilters { |
| 134 | tasks, err = applyShortcutFilters(tasks, shortcuts) |
| 135 | if err != nil { |
| 136 | return err |
| 137 | } |
| 138 | filtered = true |
| 139 | } |
| 140 | |
| 141 | // Filter tasks by status if requested |
| 142 | if len(graphExcludeStatus) > 0 { |
| 143 | excludeMap := make(map[string]bool) |