diff --git a/cmd/syft/internal/ui/__snapshots__/post_ui_event_writer_test.snap b/cmd/syft/internal/ui/__snapshots__/post_ui_event_writer_test.snap index bf473e331..64cafcab3 100755 --- a/cmd/syft/internal/ui/__snapshots__/post_ui_event_writer_test.snap +++ b/cmd/syft/internal/ui/__snapshots__/post_ui_event_writer_test.snap @@ -27,12 +27,7 @@ report 1!!> - - - - - +A newer version of syft is available for download: v0.33.0 (installed version is [not provided]) --- diff --git a/cmd/syft/internal/ui/post_ui_event_writer.go b/cmd/syft/internal/ui/post_ui_event_writer.go index e3772981b..22287d8ff 100644 --- a/cmd/syft/internal/ui/post_ui_event_writer.go +++ b/cmd/syft/internal/ui/post_ui_event_writer.go @@ -10,6 +10,7 @@ import ( "github.com/wagoodman/go-partybus" "github.com/anchore/syft/internal/log" + "github.com/anchore/syft/internal/version" "github.com/anchore/syft/syft/event" "github.com/anchore/syft/syft/event/parsers" ) @@ -118,12 +119,14 @@ func writeAppUpdate(writer io.Writer, events ...partybus.Event) error { style := lipgloss.NewStyle().Foreground(lipgloss.Color("13")).Italic(true) for _, e := range events { - notice, err := parsers.ParseCLIAppUpdateAvailable(e) + newVersion, err := parsers.ParseCLIAppUpdateAvailable(e) if err != nil { log.WithFields("error", err).Warn("failed to parse app update notification") continue } + notice := fmt.Sprintf("A newer version of syft is available for download: %s (installed version is %s)", newVersion, version.FromBuild().Version) + if _, err := fmt.Fprintln(writer, style.Render(notice)); err != nil { // don't let this be fatal log.WithFields("error", err).Warn("failed to write app update notification") diff --git a/cmd/syft/internal/ui/post_ui_event_writer_test.go b/cmd/syft/internal/ui/post_ui_event_writer_test.go index a5bdd5792..83af4d2c5 100644 --- a/cmd/syft/internal/ui/post_ui_event_writer_test.go +++ b/cmd/syft/internal/ui/post_ui_event_writer_test.go @@ -35,7 +35,7 @@ func Test_postUIEventWriter_write(t *testing.T) { }, { Type: event.CLIAppUpdateAvailable, - Value: "\n\n\n\n", + Value: "v0.33.0", }, { Type: event.CLINotification,