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)
| 539 | |
| 540 | // SelectRun prompts the user to select a run from a list of runs by using the recommended prompter interface |
| 541 | func 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 | |
| 562 | func GetRun(client *api.Client, repo ghrepo.Interface, runID string, attempt uint64) (*Run, error) { |
| 563 | var result Run |
no test coverage detected