cli

package
v0.1.0 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: 23 Imported by: 0

Documentation

Overview

Package cli builds the archive command tree on top of the ia library.

Index

Constants

This section is empty.

Variables

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

Build metadata, set via -ldflags at release time.

Functions

func Execute

func Execute(ctx context.Context, cmd *cobra.Command) int

Execute runs the root command, mapping errors to exit codes.

func ExitCode

func ExitCode(err error) int

ExitCode maps an error returned from Execute/fang to a process exit code: the codedError value when present, 2 for cobra usage errors (unknown command or flag), otherwise 1.

func Root

func Root() *cobra.Command

Root builds the root command and its whole subtree.

Types

type App

type App struct {
	Cfg   ia.Config
	HTTP  *ia.HTTPClient
	Cache *ia.Cache
	Creds *ia.Credentials
	Out   *Output
	Limit int
	// contains filtered or unexported fields
}

App carries the resolved configuration and shared clients for a command run.

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 selected format. A single Output instance handles a whole command run, so streaming formats can write incrementally.

func (*Output) Emit

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

Emit renders one row.

func (*Output) Flush

func (o *Output) Flush() error

Flush finalises buffered formats. Call once at the end of a command.

func (*Output) Format

func (o *Output) Format() Format

Format returns the resolved output format.

func (*Output) Raw

func (o *Output) Raw(b []byte) error

Raw writes bytes straight to the output (for --raw/page text/file bodies).

func (*Output) SetURLField

func (o *Output) SetURLField(f string)

SetURLField selects which column the url format emits (default "url").

type Row

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

Row is one output record: an ordered set of named columns plus the original value (used by json/jsonl and templates).

Jump to

Keyboard shortcuts

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