Documentation
¶
Overview ¶
Package shared provides helpers shared across CLI sub-packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeContext ¶
func MakeContext(timeoutMs int) (context.Context, context.CancelFunc)
MakeContext returns a context with an optional timeout. The caller must defer cancel() to avoid resource leaks.
func RegisterUsage ¶ added in v1.4.0
RegisterUsage wires the canonical `<verb> usage` subcommand. Centralised so the per-package fmt import and 4-line cobra block aren't duplicated.
func WithConnection ¶
func WithConnection(conn string, timeout int, fn func(ctx context.Context, drv driver.Connection) error) error
WithConnection resolves a connection, runs fn, and handles cleanup and error output. Errors from resolution or fn are written to stderr as structured JSON AND propagated to the caller (cobra) so the process exits non-zero. Cobra's SilenceErrors is set on the root, so the JSON is the only thing emitted on stderr.
Types ¶
Click to show internal directories.
Click to hide internal directories.