Documentation
¶
Index ¶
- Constants
- func AddWaitFlags(cmd *cobra.Command)
- func ExactArgs(n int) cobra.PositionalArgs
- func FormatBytes(bytes int64) string
- func FormatOutput(cmd *cobra.Command, data any) error
- func GetFormat(cmd *cobra.Command) string
- func NewClient(cmd *cobra.Command) (*api.Client, error)
- func WaitFor(cfg WaitConfig, checkFn func() (done bool, status string, err error)) error
- type WaitConfig
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
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
FormatBytes formats a byte count as a human-readable string.
func FormatOutput ¶ added in v0.3.3
FormatOutput applies filter, sort, and formats data to stdout.
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.
Click to show internal directories.
Click to hide internal directories.