Documentation
¶
Overview ¶
Package update provides update checking and notification functionality for the CLI. It wraps the stackeye-go-sdk update package to provide CLI-specific features like colored output and background checking during command execution.
Index ¶
Constants ¶
const ( // GitHubRepo is the repository to check for updates. GitHubRepo = "stackeye-io/stackeye-cli" // BackgroundTimeout is how long to wait for a background check to complete // when printing the notification. BackgroundTimeout = 500 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
func ShouldCheck ¶
ShouldCheck returns true if update checking should be performed. This is false for dev builds or when explicitly disabled.
Types ¶
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier manages update checks and notifications for the CLI. It wraps the SDK's Checker to provide CLI-specific functionality.
func NewNotifier ¶
func NewNotifier(currentVersion string, opts ...NotifierOption) *Notifier
NewNotifier creates a new update notifier for the CLI.
The currentVersion should be the version currently installed (e.g., "1.0.0"). Pass version.Version from the internal/version package.
Example:
notifier := update.NewNotifier(version.Version) notifier.StartCheck(ctx) // ... run command ... notifier.PrintNotification()
func (*Notifier) GetResult ¶
func (n *Notifier) GetResult() (*sdkupdate.CachedCheckResult, error)
GetResult returns the result of the background check without printing. This is useful for testing or when custom notification handling is needed.
func (*Notifier) PrintNotification ¶
PrintNotification displays an update notification if an update is available. This waits briefly for the background check to complete, then prints a notification if an update is found.
Returns true if a notification was printed, false otherwise.
func (*Notifier) StartCheck ¶
StartCheck initiates a non-blocking update check in the background. Call this early in command execution, then call PrintNotification() after the command completes to show any available updates.
type NotifierOption ¶
type NotifierOption func(*Notifier)
NotifierOption is a functional option for configuring the Notifier.
func WithCacheDir ¶
func WithCacheDir(dir string) NotifierOption
WithCacheDir sets the directory for storing the update check cache.
func WithColor ¶
func WithColor(enabled bool) NotifierOption
WithColor enables or disables colored output.
func WithWriter ¶
func WithWriter(w io.Writer) NotifierOption
WithWriter sets the output writer for notifications.