Documentation
¶
Overview ¶
Package tui owns the CLI's data-presentation contract and the theme it pushes into dry/tui at startup. Operational messaging (Info / Success / Warning / Error) is not wrapped here. Commands call the dry/tui helpers directly for those.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CLITheme ¶
CLITheme returns the safedep-cli theme. main() pushes this into dry/tui as the global default at startup, after which dry/tui Console helpers (Info / Success / Warning / Error / Print) pick it up.
Only warnings and errors carry color. Info and success render with the terminal's default foreground so routine messages do not compete visually with actionable ones.
func EnumToken ¶ added in v0.3.0
EnumToken converts a proto enum's String() form into a lowercase, hyphenated display token, shared by commands that render proto enums. It strips prefix, maps the unspecified/empty value to "unknown", lowercases, and turns underscores into hyphens. For example:
EnumToken("ANALYSIS_STATUS_IN_PROGRESS", "ANALYSIS_STATUS_") -> "in-progress"
EnumToken("BILLING_TIER_PROFESSIONAL", "BILLING_TIER_") -> "professional"
EnumToken("ECOSYSTEM_UNSPECIFIED", "ECOSYSTEM_") -> "unknown"
func IsInteractive ¶ added in v0.3.0
func IsInteractive() bool
IsInteractive reports whether the CLI can prompt the user and open a browser. It keys off the actual terminal state (stdin is a TTY, which prompt libraries need to read input) rather than the presentation mode, which is user- overridable via --output/SAFEDEP_OUTPUT and does not reflect whether a human is present. Agent mode is excluded outright so tool-driven runs never block on stdin.
Types ¶
type Mode ¶
type Mode string
Mode is the user-facing data-output selection. It governs only the data stream on stdout. Messaging on stderr (tui.Info/Success/...) is driven independently by dry/tui's own mode auto-detection.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer dispatches a Renderable to stdout in the active Mode.
func NewPrinter ¶
func (*Printer) Print ¶
func (p *Printer) Print(r Renderable) error
Print writes the Renderable to stdout in the printer's active Mode. JSON bytes are written verbatim with a trailing newline appended when the renderer did not include one.
type Renderable ¶
type Renderable interface {
RenderJSON() ([]byte, error)
RenderTable() string
RenderPlain() string
}
Renderable is implemented by command results that produce structured output. Each method emits the same data in a different format. The dispatcher (Printer.Print) picks one based on the active Mode.
Lists implement the same interface. RenderTable produces a table, RenderPlain emits a line per item, RenderJSON returns the encoded array. Pre-built helpers for common shapes are not provided yet.