cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli is the kumo command: the same use cases as the app, for people at a terminal and for coding agents. Every command accepts --json and then prints {"ok", "data", "error"} on stdout.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set by the build.

Functions

func Run

func Run(args []string, stdout, stderr io.Writer) int

Run executes kumo with args and returns the exit code.

Types

type Command

type Command struct {
	Name    string
	Aliases []string
	Summary string
	Usage   string
	// Flags lists the flags the command takes; those ending in "=" take a value.
	Flags []string
	Sub   []*Command
	Run   func(e *Env) (Result, error)
}

Command is one kumo command.

type Env

type Env struct {
	Stdout, Stderr io.Writer
	JSON           bool
	Color          bool
	DryRun         bool
	Args           []string
	Flags          map[string]string
	Kumo           func() (*application.Kumo, error)
	Ctx            context.Context
}

Env is what a command runs with.

func (*Env) Arg

func (e *Env) Arg(n int) string

Arg returns the nth positional argument, or "".

func (*Env) Bool

func (e *Env) Bool(name string) bool

Bool reports a boolean flag.

func (*Env) Flag

func (e *Env) Flag(name string) (string, bool)

Flag returns a flag's value and whether it was given.

func (*Env) Int

func (e *Env) Int(name string, fallback int) (int, error)

Int reads a numeric flag with a default.

type Result

type Result struct {
	Data any
	Text func(w *Writer)
}

Result is a command's data and how to show it as text.

type Writer

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

Writer prints text output, styled only on a terminal. Status labels are ASCII so color is never the only signal.

func (*Writer) Dim

func (w *Writer) Dim(text string) string

Dim styles secondary text.

func (*Writer) Field

func (w *Writer) Field(label string, value any)

Field prints an aligned "label value" line.

func (*Writer) Heading

func (w *Writer) Heading(text string)

Heading prints a bold line.

func (*Writer) Line

func (w *Writer) Line(text string)

Line prints one line.

func (*Writer) Status

func (w *Writer) Status(kind, message string)

Status prints "[ok] message" and its siblings.

func (*Writer) Table

func (w *Writer) Table(header []string, rows [][]string)

Table prints rows in aligned columns.

func (*Writer) Value

func (w *Writer) Value(v any)

Value prints any data as indented JSON, for commands without a text rendering.

Jump to

Keyboard shortcuts

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