MCPcopy
hub / github.com/cli/cli / RenderJobsCompact

Function RenderJobsCompact

pkg/cmd/run/shared/presentation.go:50–90  ·  view source on GitHub ↗
(cs *iostreams.ColorScheme, jobs []Job)

Source from the content-addressed store, hash-verified

48}
49
50func RenderJobsCompact(cs *iostreams.ColorScheme, jobs []Job) string {
51 lines := []string{}
52 for _, job := range jobs {
53 elapsed := job.CompletedAt.Sub(job.StartedAt)
54 elapsedStr := fmt.Sprintf(" in %s", elapsed)
55 if elapsed < 0 {
56 elapsedStr = ""
57 }
58 symbol, symbolColor := Symbol(cs, job.Status, job.Conclusion)
59 id := cs.Cyanf("%d", job.ID)
60 lines = append(lines, fmt.Sprintf("%s %s%s (ID %s)", symbolColor(symbol), cs.Bold(job.Name), elapsedStr, id))
61
62 if job.Status == Completed && job.Conclusion == Success {
63 continue
64 }
65
66 var inProgressStepLine string
67 var failedStepLines []string
68
69 for _, step := range job.Steps {
70 stepSymbol, stepSymColor := Symbol(cs, step.Status, step.Conclusion)
71 stepLine := fmt.Sprintf(" %s %s", stepSymColor(stepSymbol), step.Name)
72
73 if IsFailureState(step.Conclusion) {
74 failedStepLines = append(failedStepLines, stepLine)
75 }
76
77 if step.Status == InProgress {
78 inProgressStepLine = stepLine
79 }
80 }
81
82 lines = append(lines, failedStepLines...)
83
84 if inProgressStepLine != "" {
85 lines = append(lines, inProgressStepLine)
86 }
87 }
88
89 return strings.Join(lines, "\n")
90}
91
92func RenderAnnotations(cs *iostreams.ColorScheme, annotations []Annotation) string {
93 lines := []string{}

Callers 2

renderRunFunction · 0.92
TestRenderJobsFunction · 0.85

Calls 5

SymbolFunction · 0.85
IsFailureStateFunction · 0.85
CyanfMethod · 0.80
BoldMethod · 0.80
JoinMethod · 0.80

Tested by 1

TestRenderJobsFunction · 0.68