cmdutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cmdutil provides shared helpers for building SDK-backed CLI commands. Every namespace command follows the same pattern:

  • Optional --json flag accepts a raw JSON payload (overrides typed flags)
  • Optional --output flag (json | ndjson | text)
  • Optional --dry-run flag prints the request and exits
  • Results are written to an io.Writer for testability

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseJSON

func ParseJSON(s string, dst any) error

ParseJSON unmarshals a JSON string into dst.

func RunCommand

func RunCommand(ctx context.Context, w io.Writer, reqBody any, dryRun bool, outputFormat string, runFn RunFunc) error

RunCommand executes a SDK-backed command with standard --json / --output / --dry-run handling. reqBody is the request that WOULD be sent (shown on --dry-run). runFn is the actual SDK call, only invoked when dryRun is false.

Types

type RunFunc

type RunFunc func(ctx context.Context) (any, error)

RunFunc is a function that calls the SDK and returns a result to be serialized.

Jump to

Keyboard shortcuts

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