MCPcopy
hub / github.com/cli/cli / SelectRun

Function SelectRun

pkg/cmd/run/shared/shared.go:518–537  ·  view source on GitHub ↗

SelectRun prompts the user to select a run from a list of runs by using the recommended prompter interface

(p Prompter, cs *iostreams.ColorScheme, runs []Run)

Source from the content-addressed store, hash-verified

516
517// SelectRun prompts the user to select a run from a list of runs by using the recommended prompter interface
518func SelectRun(p Prompter, cs *iostreams.ColorScheme, runs []Run) (string, error) {
519 now := time.Now()
520
521 candidates := []string{}
522
523 for _, run := range runs {
524 symbol, _ := Symbol(cs, run.Status, run.Conclusion)
525 candidates = append(candidates,
526 // TODO truncate commit message, long ones look terrible
527 fmt.Sprintf("%s %s, %s [%s] %s", symbol, run.Title(), run.WorkflowName(), run.HeadBranch, preciseAgo(now, run.StartedTime())))
528 }
529
530 selected, err := p.Select("Select a workflow run", "", candidates)
531
532 if err != nil {
533 return "", err
534 }
535
536 return fmt.Sprintf("%d", runs[selected].ID), nil
537}
538
539func GetRun(client *api.Client, repo ghrepo.Interface, runID string, attempt uint64) (*Run, error) {
540 var result Run

Callers 5

runRerunFunction · 0.92
runDeleteFunction · 0.92
runViewFunction · 0.92
watchRunFunction · 0.92
runCancelFunction · 0.92

Calls 6

SymbolFunction · 0.85
preciseAgoFunction · 0.85
WorkflowNameMethod · 0.80
StartedTimeMethod · 0.80
TitleMethod · 0.65
SelectMethod · 0.65

Tested by

no test coverage detected