update

package
v0.2.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 6 Imported by: 0

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

View Source
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

func ShouldCheck(currentVersion string, disabled bool) bool

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

func (n *Notifier) PrintNotification() bool

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

func (n *Notifier) StartCheck(ctx context.Context)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL