share annotation printing

This commit is contained in:
vilmibm 2021-03-29 16:34:17 -05:00
parent 43ab74a023
commit e7fa99b70f
2 changed files with 12 additions and 5 deletions

View file

@ -36,3 +36,14 @@ func RenderJobs(cs *iostreams.ColorScheme, jobs []Job, verbose bool) string {
return strings.Join(lines, "\n")
}
func RenderAnnotations(cs *iostreams.ColorScheme, annotations []Annotation) string {
lines := []string{}
for _, a := range annotations {
lines = append(lines, fmt.Sprintf("%s %s", AnnotationSymbol(cs, a), a.Message))
lines = append(lines, cs.Grayf("%s: %s#%d\n", a.JobName, a.Path, a.StartLine))
}
return strings.Join(lines, "\n")
}

View file

@ -164,12 +164,8 @@ func runView(opts *ViewOptions) error {
if len(annotations) > 0 {
fmt.Fprintln(out)
fmt.Fprintln(out, cs.Bold("ANNOTATIONS"))
fmt.Fprintln(out, shared.RenderAnnotations(cs, annotations))
for _, a := range annotations {
fmt.Fprintf(out, "%s %s\n", shared.AnnotationSymbol(cs, a), a.Message)
fmt.Fprintln(out, cs.Grayf("%s: %s#%d\n",
a.JobName, a.Path, a.StartLine))
}
}
fmt.Fprintln(out)