command

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachCustomerCommands added in v0.1.1

func AttachCustomerCommands(cmd *cobra.Command, commandOpts RootCommandOptions)

AttachCustomerCommands wires the full customer command tree (auth, iam, vm, disk, network, ...) onto a root that's already been built by pkg/metalhostcli/runtime.NewRootCommand. Use this when something else owns the bare root setup — typically the metalhostcli package wrapping a runtime-built root for the `metalhost` binary.

The persistent flags on `cmd` are bound to runtime's rootOptions, not ours. We bridge by re-reading flag values into our struct in PersistentPreRunE, which cobra invokes on the root before any leaf RunE.

func HandleError added in v1.0.0

func HandleError(w io.Writer, err error) int

HandleError renders err to w in a human-friendly way and returns the process exit code. It unwraps connect errors to show the status + message + an actionable hint instead of the raw "unauthenticated: ..." string, and maps the connect code to a stable exit code for scripting.

func NewRootCommand

func NewRootCommand() *cobra.Command

func NewRootCommandWithOptions

func NewRootCommandWithOptions(commandOpts RootCommandOptions) *cobra.Command

NewRootCommandWithOptions builds a fully-loaded customer CLI root in one call. Used by the in-package tests and as a back-compat single-shot entry point. The two-step path (runtime.NewRootCommand → AttachCustomerCommands) is preferred for callers who want to opt out of the customer command tree.

Types

type RootCommandOptions

type RootCommandOptions struct {
	Use       string
	Short     string
	UserAgent string
}

Jump to

Keyboard shortcuts

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