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

Function githubStatusCmd

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

Source from the content-addressed store, hash-verified

215}
216
217func 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
223Examples:
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 })

Callers 1

githubCmdFunction · 0.85

Calls 11

ItemRefFunction · 0.92
PrintJSONFunction · 0.92
getClientFunction · 0.85
getWorkspaceFunction · 0.85
showItemPRStatusFunction · 0.85
extractPRFromItemFunction · 0.85
prStateColorFunction · 0.85
relativeTimeStrFunction · 0.85
ListCollectionItemsMethod · 0.80
GetItemMethod · 0.45
ListCollectionsMethod · 0.45

Tested by

no test coverage detected