mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
37 lines
936 B
Go
37 lines
936 B
Go
//go:build linux || darwin || netbsd
|
|
// +build linux darwin netbsd
|
|
|
|
package ui
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"sync"
|
|
|
|
"github.com/gookit/color"
|
|
"github.com/wagoodman/go-partybus"
|
|
"github.com/wagoodman/jotframe/pkg/frame"
|
|
|
|
"github.com/anchore/syft/internal"
|
|
syftEventParsers "github.com/anchore/syft/syft/event/parsers"
|
|
)
|
|
|
|
// handleAppUpdateAvailable is a UI handler function to display a new application version to the top of the screen.
|
|
func handleAppUpdateAvailable(_ context.Context, fr *frame.Frame, event partybus.Event, _ *sync.WaitGroup) error {
|
|
newVersion, err := syftEventParsers.ParseAppUpdateAvailable(event)
|
|
if err != nil {
|
|
return fmt.Errorf("bad AppUpdateAvailable event: %w", err)
|
|
}
|
|
|
|
line, err := fr.Prepend()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
message := color.Magenta.Sprintf("New version of %s is available: %s", internal.ApplicationName, newVersion)
|
|
_, _ = io.WriteString(line, message)
|
|
|
|
return nil
|
|
}
|