cmdutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWaitInterval = 10 * time.Second
	DefaultWaitTimeout  = 5 * time.Minute
)

Variables

This section is empty.

Functions

func AddWaitFlags added in v0.3.3

func AddWaitFlags(cmd *cobra.Command)

AddWaitFlags adds --wait and --wait-timeout flags to a command.

func ExactArgs added in v0.1.4

func ExactArgs(n int) cobra.PositionalArgs

ExactArgs returns a PositionalArgs that reports the command's Use line on mismatch.

func FormatBytes added in v0.3.3

func FormatBytes(bytes int64) string

FormatBytes formats a byte count as a human-readable string.

func FormatOutput added in v0.3.3

func FormatOutput(cmd *cobra.Command, data any) error

FormatOutput applies filter, sort, and formats data to stdout.

func GetFormat

func GetFormat(cmd *cobra.Command) string

GetFormat returns the output format from flags.

func NewClient

func NewClient(cmd *cobra.Command) (*api.Client, error)

NewClient creates an API client from the cobra command context.

func WaitFor added in v0.3.3

func WaitFor(cfg WaitConfig, checkFn func() (done bool, status string, err error)) error

WaitFor polls checkFn until it returns done=true or an error occurs. checkFn returns (done, status, error):

  • done=true: success, stop polling
  • done=false: keep polling, print status
  • err!=nil: abort with error

Types

type WaitConfig added in v0.3.3

type WaitConfig struct {
	Interval time.Duration
	Timeout  time.Duration
	Resource string // e.g. "server my-server"
}

WaitConfig holds parameters for the polling loop.

func GetWaitConfig added in v0.3.3

func GetWaitConfig(cmd *cobra.Command, resource string) *WaitConfig

GetWaitConfig reads --wait and --wait-timeout flags from the command. Returns nil if --wait is not set.

Jump to

Keyboard shortcuts

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