| 51 | } |
| 52 | |
| 53 | func runProjects(_ *cobra.Command, _ []string) error { |
| 54 | projects, err := LoadGlobalRegistry() |
| 55 | if err != nil { |
| 56 | return fmt.Errorf("loading registry: %w", err) |
| 57 | } |
| 58 | |
| 59 | if len(projects) == 0 { |
| 60 | fmt.Fprintln(os.Stderr, "No projects registered. Add projects to ~/.taskmd/config.yaml:") |
| 61 | fmt.Fprintln(os.Stderr, "") |
| 62 | fmt.Fprintln(os.Stderr, " projects:") |
| 63 | fmt.Fprintln(os.Stderr, " - id: my-project") |
| 64 | fmt.Fprintln(os.Stderr, " name: \"My Project\"") |
| 65 | fmt.Fprintln(os.Stderr, " path: /path/to/project") |
| 66 | return nil |
| 67 | } |
| 68 | |
| 69 | summaries := collectProjectSummaries(projects) |
| 70 | |
| 71 | switch projectsFormat { |
| 72 | case "json": |
| 73 | return WriteJSON(os.Stdout, summaries) |
| 74 | case "yaml": |
| 75 | return WriteYAML(os.Stdout, summaries) |
| 76 | case "table": |
| 77 | return outputProjectsTable(summaries) |
| 78 | default: |
| 79 | return ValidateFormat(projectsFormat, []string{"table", "json", "yaml"}) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // projectDirConfig is a minimal struct to read the task directory from .taskmd.yaml. |
| 84 | type projectDirConfig struct { |