cli

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package cli is the cobra command tree for the amz CLI.

Index

Constants

View Source
const (
	CodeOK      = 0
	CodeRuntime = 1
	CodeUsage   = 2
	CodeNoData  = 3
	CodePartial = 4
	CodeBlocked = 5
)

Exit codes (mirrors spec §6).

Variables

View Source
var (
	Version = "dev"
	Commit  = "none"
	Date    = "unknown"
)

Version metadata, overridable at build time via -ldflags.

Functions

func Root

func Root() *cobra.Command

Root builds the full command tree.

Types

type App

type App struct {
	Marketplace string
	OutputFmt   string
	Fields      string
	Limit       int
	DataDir     string
	Workers     int
	Rate        time.Duration
	Retries     int
	Timeout     time.Duration
	Cookies     string
	UseAPI      bool
	Quiet       bool
	Verbose     bool
	Color       string
	NoCache     bool
	Refresh     bool
	DryRun      bool
	Raw         bool
	OutFile     string
	NoHeader    bool
	Template    string
	ConfigPath  string

	// Out is where rendered records go (cobra's stdout, or a file for -O).
	Out io.Writer
}

App holds the resolved global flags shared by every command.

func (*App) Client

func (a *App) Client() (*amz.Client, error)

Client builds a polite, block-aware client for the resolved marketplace.

func (*App) Config

func (a *App) Config() amz.Config

Config builds an amz.Config from the resolved global flags.

func (*App) Output

func (a *App) Output() (*Output, error)

Output builds the output renderer for this run.

type ExitError

type ExitError struct {
	Code int
	Err  error
}

ExitError carries a specific process exit code out of a command.

func (*ExitError) Error

func (e *ExitError) Error() string

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

type Format

type Format string

Format is an output encoding.

const (
	FormatAuto  Format = "auto"
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatJSONL Format = "jsonl"
	FormatCSV   Format = "csv"
	FormatTSV   Format = "tsv"
	FormatURL   Format = "url"
	FormatRaw   Format = "raw"
)

type Output

type Output struct {
	// contains filtered or unexported fields
}

Output renders rows in the chosen format, streaming where possible.

func NewOutput

func NewOutput(w io.Writer, format Format, isTTY bool, fields []string, noHeader bool, tmpl string) (*Output, error)

NewOutput builds an Output for the resolved format.

func (*Output) Close

func (o *Output) Close() error

Close flushes any buffered output (table alignment, JSON array close).

func (*Output) Count

func (o *Output) Count() int

Count returns how many rows were emitted.

func (*Output) Emit

func (o *Output) Emit(r Row) error

Emit renders one row.

type Row

type Row struct {
	Cols  []string
	Vals  []string
	Value any
	URL   string
}

Row is one renderable record: an ordered set of columns and the raw value behind them (used by json/jsonl output).

Jump to

Keyboard shortcuts

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