cli

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Overview

Package cli defines the audd command tree.

Each command group lives in its own file and adds itself with Register from an init() function, so files never need to edit root.go:

func init() {
	Register(func(root *cobra.Command, a *app.App) {
		root.AddCommand(newStreamsCmd(a))
	})
}

Register callbacks run when the tree is built, before flags are parsed. The *app.App they receive is filled in (config, secrets, printer, flags) by the root's PersistentPreRunE before any RunE runs, so read its fields inside RunE, not in the callback.

Index

Constants

View Source
const (
	GroupRecognize = "recognize"
	GroupStreams   = "streams"
	GroupAccount   = "account"
	GroupLocal     = "local"
	GroupAgents    = "agents"
	GroupOther     = "other"
)

Command groups shown in `audd --help`. Set cmd.GroupID to one of these.

View Source
const AnnotationStreaming = "audd:streaming"

AnnotationStreaming marks a command whose piped output defaults to JSONL (cmd.Annotations[AnnotationStreaming] = "true"). Commands that only sometimes stream call a.Out.SetStreaming() at run time instead.

Variables

This section is empty.

Functions

func Execute

func Execute() int

Execute runs audd with os.Args and the real terminal; it returns the exit code.

func Main

func Main(args []string, stdin io.Reader, stdout, stderr io.Writer) int

Main runs audd with the given arguments and streams, none of them a TTY. Tests use it (see testutil.Exec).

func Register

func Register(f func(root *cobra.Command, a *app.App))

Register adds a function that attaches commands to the root. Call it from init().

func Run

func Run(ctx context.Context, args []string, stdio IO) int

Run builds a fresh command tree and runs it; it returns the exit code.

Types

type IO

type IO struct {
	In                             io.Reader
	Out, Err                       io.Writer
	StdinTTY, StdoutTTY, StderrTTY bool
	// StderrWidth is the terminal width of Err; 0 reads it from the terminal.
	StderrWidth int
	// StdoutWidth is the terminal width of Out; 0 reads it from the terminal.
	StdoutWidth int
}

IO is the process environment a run uses.

type VersionInfo

type VersionInfo struct {
	Version string `json:"version"`
	Commit  string `json:"commit"`
	Date    string `json:"date"`
	Go      string `json:"go"`
	OS      string `json:"os"`
	Arch    string `json:"arch"`
}

VersionInfo is the output of `audd version`.

Jump to

Keyboard shortcuts

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