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

Function SelectRun

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

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