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