From e7fa99b70f77ad9916b0d929bb19ea40d40a01f1 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 29 Mar 2021 16:34:17 -0500 Subject: [PATCH] share annotation printing --- pkg/cmd/run/shared/presentation.go | 11 +++++++++++ pkg/cmd/run/view/view.go | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/run/shared/presentation.go b/pkg/cmd/run/shared/presentation.go index b0ff2f882..4886e89f7 100644 --- a/pkg/cmd/run/shared/presentation.go +++ b/pkg/cmd/run/shared/presentation.go @@ -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") +} diff --git a/pkg/cmd/run/view/view.go b/pkg/cmd/run/view/view.go index 8005cf0f1..078ff23c3 100644 --- a/pkg/cmd/run/view/view.go +++ b/pkg/cmd/run/view/view.go @@ -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)