cmd

package
v0.0.0-...-8f9dc6d Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version remains only as a compatibility fallback for older build scripts. New release builds inject main.version and pass it through BuildInfo.

Functions

func Execute

func Execute(build ...BuildInfo) error

Execute builds a fresh command tree on every call. main should handle the returned error and map it to a process exit code.

func ExecuteContext

func ExecuteContext(ctx context.Context, deps Dependencies, info BuildInfo, args []string) error

func ExitCode

func ExitCode(err error) int

func NewRootCommand

func NewRootCommand(deps Dependencies, info BuildInfo) *cobra.Command

func RenderHello

func RenderHello(info BuildInfo, latestVersion string, hasUpdate bool, useColor bool) string

RenderHello returns the complete hello window as a string, without a trailing newline. The caller is responsible for writing it.

func RenderHelpDocs

func RenderHelpDocs(command *cobra.Command)

func RenderHelpTree

func RenderHelpTree(command *cobra.Command, maxDepth int, showGlobalFlags bool)

func WriteFinalRecovery

func WriteFinalRecovery(err error, out io.Writer) bool

WriteFinalRecovery writes an upgrade recovery block after the ordinary error diagnostic so the directly executable installer command is the final output.

Types

type BuildInfo

type BuildInfo struct {
	Version   string `json:"version"`
	Commit    string `json:"commit,omitempty"`
	BuildDate string `json:"build_date,omitempty"`
	Target    string `json:"target,omitempty"`
}

type Dependencies

type Dependencies struct {
	In               io.Reader
	Out              io.Writer
	Err              io.Writer
	Getwd            func() (string, error)
	HomeDir          func() (string, error)
	Runner           versioning.Runner
	HookRunner       hooks.CommandRunner
	HTTPClient       *http.Client
	Now              func() time.Time
	Executable       func() (string, error)
	ReadUpdateNotice func(string, time.Time) string
	LaunchUpdate     func(string, string) error
	ConsumeUpgrade   func() (*updater.Completion, error)
	ReconcileUpgrade func(string) error
	ReconcileBinary  func(string, string) error
	BootstrapAgents  func(string) error
	IsTerminal       func() bool
}

Jump to

Keyboard shortcuts

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