()
| 215 | } |
| 216 | |
| 217 | func githubStatusCmd() *cobra.Command { |
| 218 | return &cobra.Command{ |
| 219 | Use: "status [item-ref]", |
| 220 | Short: "Show GitHub PR status for linked items", |
| 221 | Long: `Show the GitHub PR status for one or all items that have linked PRs. |
| 222 | |
| 223 | Examples: |
| 224 | pad github status # Show all items with linked PRs |
| 225 | pad github status TASK-5 # Show PR status for a specific item`, |
| 226 | Args: cobra.MaximumNArgs(1), |
| 227 | RunE: func(cmd *cobra.Command, args []string) error { |
| 228 | client, _ := getClient() |
| 229 | ws := getWorkspace() |
| 230 | |
| 231 | bold := color.New(color.Bold) |
| 232 | dim := color.New(color.Faint) |
| 233 | |
| 234 | if len(args) > 0 { |
| 235 | // Single item mode |
| 236 | item, err := client.GetItem(ws, args[0]) |
| 237 | if err != nil { |
| 238 | return err |
| 239 | } |
| 240 | return showItemPRStatus(item, bold, dim) |
| 241 | } |
| 242 | |
| 243 | // All items mode — scan across all collections for items with github_pr in fields |
| 244 | colls, err := client.ListCollections(ws) |
| 245 | if err != nil { |
| 246 | return err |
| 247 | } |
| 248 | var items []models.Item |
| 249 | for _, coll := range colls { |
| 250 | collItems, err := client.ListCollectionItems(ws, coll.Slug, url.Values{ |
| 251 | "limit": {"100"}, |
| 252 | "include_archived": {"true"}, |
| 253 | }) |
| 254 | if err != nil { |
| 255 | continue |
| 256 | } |
| 257 | items = append(items, collItems...) |
| 258 | } |
| 259 | |
| 260 | if formatFlag == "json" { |
| 261 | type prStatus struct { |
| 262 | Ref string `json:"ref"` |
| 263 | Title string `json:"title"` |
| 264 | PR GitHubPR `json:"github_pr"` |
| 265 | } |
| 266 | var results []prStatus |
| 267 | for _, item := range items { |
| 268 | pr := extractPRFromItem(&item) |
| 269 | if pr != nil { |
| 270 | results = append(results, prStatus{ |
| 271 | Ref: cli.ItemRef(item), |
| 272 | Title: item.Title, |
| 273 | PR: *pr, |
| 274 | }) |
no test coverage detected