cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cli holds the output plumbing shared by the fleet binaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clip

func Clip(s string, limit int, mark string) string

Clip bounds a string to limit bytes, cutting on a rune boundary and marking the cut with mark.

Bytes rather than display columns, because this bounds what one machine may contribute to a structured result — a JSON field, a stored row — where the budget is memory. Fitting text to a column of a terminal is a different job, done against the rendered width; see internal/tui.

The marker is the caller's rather than "…" here, because only the caller knows what its output device can render. A JSON field or a table on a UTF-8 terminal wants the one character; a frame that may be drawn on a terminal reading a legacy code page wants three dots, and a helper that decided for both would be the one place a full-screen view could not stop a multi-byte character reaching a screen that cannot show it.

func HumanBytes

func HumanBytes(n uint64) string

HumanBytes renders a byte count in the largest unit that keeps it under four digits, and an unknown quantity — zero — as the empty string. Raw byte counts of a disk are unreadable and, at three or four per sandbox, not cheap either.

func HumanDuration

func HumanDuration(d time.Duration) string

HumanDuration renders an uptime without the sub-second noise time.Duration's own formatting carries.

func RelativeTime

func RelativeTime(t time.Time, now time.Time) string

RelativeTime renders how long ago t was, compactly. An unset time reads "never", which is what a sandbox that has not answered a probe deserves.

func SafeText

func SafeText(msg string) string

SafeText makes an agent-supplied string safe to print on a terminal.

Control characters are dropped, not escaped and not turned into spaces, and runs of whitespace collapse to one space. Everything a sandbox says about itself — a health message, a process name, a line of a log — arrives from a machine running someone else's code and lands on the operator's screen. A terminal escape in a fleet listing is a lie about the fleet, and in a full-screen view it is worse: one escape sequence can move the cursor out of the pane it was drawn in and corrupt every frame after it.

A discarded escape does not become a space, because a gap where one was would split a single word into two that then read as separate columns.

Types

type Printer

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

Printer writes command output, remembering the first write error.

Commands print several lines in sequence, and checking every one inline would bury the logic. Recording the first failure and reporting it once, at the end, means a command whose output went nowhere — a closed pipe, a full disk — exits non-zero instead of silently claiming success.

func NewPrinter

func NewPrinter(w io.Writer) *Printer

NewPrinter returns a Printer writing to w.

func (*Printer) Err

func (p *Printer) Err() error

Err returns the first write error, if any.

func (*Printer) Printf

func (p *Printer) Printf(format string, args ...any)

Printf writes a formatted line.

func (*Printer) Println

func (p *Printer) Println(args ...any)

Println writes a line.

func (*Printer) Write

func (p *Printer) Write(b []byte)

write emits raw bytes, for output that is a file's contents rather than a formatted line.

Directories

Path Synopsis
Package fleetagent implements the fleet-agent CLI: enrollment, the daemon itself, and registration with the platform's service manager.
Package fleetagent implements the fleet-agent CLI: enrollment, the daemon itself, and registration with the platform's service manager.
Package fleetctl implements the operator CLI for the fleet control plane: certificate authority management, enrollment token minting, the enrollment listener, and the operator's view of the fleet.
Package fleetctl implements the operator CLI for the fleet control plane: certificate authority management, enrollment token minting, the enrollment listener, and the operator's view of the fleet.
Package fleetmcp implements the fleet-mcp CLI: the MCP server an agent CLI launches over stdio.
Package fleetmcp implements the fleet-mcp CLI: the MCP server an agent CLI launches over stdio.

Jump to

Keyboard shortcuts

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