cliapp

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const APIBase = "/api/v4.0"

Variables

This section is empty.

Functions

func AddEnabledFlag

func AddEnabledFlag(cmd *cobra.Command)

AddEnabledFlag adds --enabled flag accepting "yes" or "no".

func AddListFlags

func AddListFlags(cmd *cobra.Command)

func ConfirmDelete

func ConfirmDelete(stdout, stderr io.Writer, resource, id string, yes bool) error

ConfirmDelete asks for interactive confirmation before a destructive operation. In TTY mode without --yes, it prompts "Delete <resource> <id>? y/N". In non-TTY mode without --yes, it returns an error requiring --yes.

func GetListParams

func GetListParams(cmd *cobra.Command) (page, pageSize int, filter, order, orderBy string)

func ListParams

func ListParams(page, pageSize int, filter, order, orderBy string) map[string]string

func MergeDataWithFlags

func MergeDataWithFlags(dataJSON string, cmd *cobra.Command, fieldMap map[string]string) (map[string]interface{}, error)

MergeDataWithFlags parses --data JSON, then overlays any explicitly set semantic flags (from fieldMap). Flags override data fields. fieldMap key = CLI flag name, value = API field name.

func ParseJSON

func ParseJSON(s string) (interface{}, error)

Types

type AuthError

type AuthError struct {
	Message string
}

AuthError indicates missing or invalid authentication.

func (*AuthError) Error

func (e *AuthError) Error() string

type Runtime

type Runtime struct {
	Session        *session.Session
	APIClient      *api.Client
	CredSource     string // "token", "env", or "none"
	Format         output.Format
	RawMode        bool
	HumanTime      bool
	DryRun         bool
	DefaultColumns []string // Per-command default columns for table output.
	UserColumns    []string // User-specified columns via --columns flag.
	WideMode       bool     // Show all columns (--wide).
	TermWidth      int      // Terminal width; 0 = unknown.
	Stdout         io.Writer
	Stderr         io.Writer
}

func New

func New(stdout, stderr io.Writer) *Runtime

func (*Runtime) LoadSession

func (r *Runtime) LoadSession() (*session.Session, error)

func (*Runtime) NewClient

func (r *Runtime) NewClient(baseURL, token string) *api.Client

func (*Runtime) PrintJSON

func (r *Runtime) PrintJSON(v interface{})

PrintJSON renders a Go value (map, struct) using the configured format.

func (*Runtime) PrintRaw

func (r *Runtime) PrintRaw(raw json.RawMessage)

PrintRaw renders raw API JSON bytes using the configured format. In --raw mode, outputs pretty-printed full envelope.

func (*Runtime) RequireAuth

func (r *Runtime) RequireAuth() error

func (*Runtime) RequireURL

func (r *Runtime) RequireURL() error

func (*Runtime) SyncSession

func (r *Runtime) SyncSession() error

type ValidationError

type ValidationError struct {
	Message string
}

ValidationError indicates invalid user input (bad JSON, invalid flag values).

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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