| 60 | } |
| 61 | |
| 62 | func runFeed(_ *cobra.Command, _ []string) error { |
| 63 | if err := ValidateFormat(feedFormat, []string{"text", "json"}); err != nil { |
| 64 | return err |
| 65 | } |
| 66 | |
| 67 | validSources := map[string]bool{"all": true, "git": true, "worklog": true} |
| 68 | if !validSources[feedSource] { |
| 69 | return fmt.Errorf("unsupported source: %q (supported: all, git, worklog)", feedSource) |
| 70 | } |
| 71 | |
| 72 | flags := GetGlobalFlags() |
| 73 | |
| 74 | entries, err := feed.Query(feed.Options{ |
| 75 | TasksDir: flags.TaskDir, |
| 76 | Limit: feedLimit, |
| 77 | Since: feedSince, |
| 78 | Scope: feedScope, |
| 79 | Source: feedSource, |
| 80 | Verbose: flags.Verbose, |
| 81 | GitLogFn: gitLogFunc, |
| 82 | GitShowFn: gitShowFunc, |
| 83 | }) |
| 84 | if err != nil { |
| 85 | return fmt.Errorf("failed to read git history (is this a git repository?): %w", err) |
| 86 | } |
| 87 | |
| 88 | if len(entries) == 0 { |
| 89 | if feedFormat == "text" { |
| 90 | fmt.Println("No recent task changes.") |
| 91 | } else { |
| 92 | fmt.Print("[]\n") |
| 93 | } |
| 94 | return nil |
| 95 | } |
| 96 | |
| 97 | switch feedFormat { |
| 98 | case "json": |
| 99 | return WriteJSON(os.Stdout, entries) |
| 100 | default: |
| 101 | return writeFeedText(entries) |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | func runGitLog(_ string, args []string) (string, error) { |
| 106 | cmd := exec.Command("git", args...) |