MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / githubStatusCmd

Function githubStatusCmd

cmd/pad/cmd_github.go:282–372  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

280}
281
282func githubStatusCmd() *cobra.Command {
283 return &cobra.Command{
284 Use: "status [item-ref]",
285 Short: "Show GitHub PR status for linked items",
286 Long: `Show the GitHub PR status for one or all items that have linked PRs.`,
287 Example: ` pad github status # Show all items with linked PRs
288 pad github status TASK-5 # Show PR status for a specific item`,
289 Args: cobra.MaximumNArgs(1),
290 RunE: func(cmd *cobra.Command, args []string) error {
291 client, _ := getClient()
292 ws := getWorkspace()
293
294 bold := color.New(color.Bold)
295 dim := color.New(color.Faint)
296
297 if len(args) > 0 {
298 // Single item mode
299 item, err := client.GetItem(ws, args[0])
300 if err != nil {
301 return err
302 }
303 return showItemPRStatus(item, bold, dim)
304 }
305
306 // All items mode — scan across all collections for items with github_pr in fields
307 items, err := githubStatusScanItems(client, ws)
308 if err != nil {
309 return err
310 }
311
312 if formatFlag == "json" {
313 type prStatus struct {
314 Ref string `json:"ref"`
315 Title string `json:"title"`
316 PR GitHubPR `json:"github_pr"`
317 }
318 var results []prStatus
319 for _, item := range items {
320 pr := extractPRFromItem(&item)
321 if pr != nil {
322 results = append(results, prStatus{
323 Ref: cli.ItemRef(item),
324 Title: item.Title,
325 PR: *pr,
326 })
327 }
328 }
329 return cli.PrintJSON(results)
330 }
331
332 tw := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0)
333 fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\n",
334 dim.Sprint("REF"), dim.Sprint("TITLE"), dim.Sprint("PR"), dim.Sprint("STATE"), dim.Sprint("UPDATED"))
335 fmt.Fprintf(tw, "%s\t%s\t%s\t%s\t%s\n",
336 dim.Sprint("───"), dim.Sprint("─────"), dim.Sprint("──"), dim.Sprint("─────"), dim.Sprint("───────"))
337
338 count := 0
339 for _, item := range items {

Callers 1

githubCmdFunction · 0.85

Calls 13

ItemRefFunction · 0.92
PrintJSONFunction · 0.92
getClientFunction · 0.85
getWorkspaceFunction · 0.85
showItemPRStatusFunction · 0.85
githubStatusScanItemsFunction · 0.85
extractPRFromItemFunction · 0.85
appendFunction · 0.85
prStateColorFunction · 0.85
relativeTimeStrFunction · 0.85
PrintfMethod · 0.80
GetItemMethod · 0.45

Tested by

no test coverage detected