MCPcopy Create free account
hub / github.com/cli/cli / SelectRun

Function SelectRun

pkg/cmd/run/shared/shared.go:538–557  ·  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

536
537// SelectRun prompts the user to select a run from a list of runs by using the recommended prompter interface
538func SelectRun(p Prompter, cs *iostreams.ColorScheme, runs []Run) (string, error) {
539 now := time.Now()
540
541 candidates := []string{}
542
543 for _, run := range runs {
544 symbol, _ := Symbol(cs, run.Status, run.Conclusion)
545 candidates = append(candidates,
546 // TODO truncate commit message, long ones look terrible
547 fmt.Sprintf("%s %s, %s [%s] %s", symbol, run.Title(), run.WorkflowName(), run.HeadBranch, preciseAgo(now, run.StartedTime())))
548 }
549
550 selected, err := p.Select("Select a workflow run", "", candidates)
551
552 if err != nil {
553 return "", err
554 }
555
556 return fmt.Sprintf("%d", runs[selected].ID), nil
557}
558
559func GetRun(client *api.Client, repo ghrepo.Interface, runID string, attempt uint64) (*Run, error) {
560 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