| 26 | } |
| 27 | |
| 28 | func RenderJobs(cs *iostreams.ColorScheme, jobs []Job, verbose bool) string { |
| 29 | lines := []string{} |
| 30 | for _, job := range jobs { |
| 31 | elapsed := job.CompletedAt.Sub(job.StartedAt) |
| 32 | elapsedStr := fmt.Sprintf(" in %s", elapsed) |
| 33 | if elapsed < 0 { |
| 34 | elapsedStr = "" |
| 35 | } |
| 36 | symbol, symbolColor := Symbol(cs, job.Status, job.Conclusion) |
| 37 | id := cs.Cyanf("%d", job.ID) |
| 38 | lines = append(lines, fmt.Sprintf("%s %s%s (ID %s)", symbolColor(symbol), cs.Bold(job.Name), elapsedStr, id)) |
| 39 | if verbose || IsFailureState(job.Conclusion) { |
| 40 | for _, step := range job.Steps { |
| 41 | stepSymbol, stepSymColor := Symbol(cs, step.Status, step.Conclusion) |
| 42 | lines = append(lines, fmt.Sprintf(" %s %s", stepSymColor(stepSymbol), step.Name)) |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | return strings.Join(lines, "\n") |
| 48 | } |
| 49 | |
| 50 | func RenderJobsCompact(cs *iostreams.ColorScheme, jobs []Job) string { |
| 51 | lines := []string{} |