shared

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 8 Imported by: 0

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

func RegisterUsage(parent *cobra.Command, verb, text string)

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.

Types

type GlobalFlags

type GlobalFlags struct {
	Connection string
	Format     string
	Expand     string
	Full       bool
	Timeout    int
	Compact    bool
}

GlobalFlags holds global CLI flag values shared across sub-packages.

Jump to

Keyboard shortcuts

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