cli

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package cli is ovdb's command-line presentation of the onboarding and configuration capabilities: `ovdb server …`, `ovdb open`, `ovdb config …` and `ovdb status`. Commands resolve environment-dependent inputs, call the local server (or the pure reads in internal/setup) and render the resulting documents; --json prints those documents unchanged.

Every user-facing command is visible, exits 0 on success and 1 on any failure, and reports failures in the shared error envelope.

Index

Constants

View Source
const EnvNonInteractive = "OVDB_NON_INTERACTIVE"

EnvNonInteractive forces bare `ovdb`'s non-interactive path even when stdin and stdout are both terminals — an AI agent harness that still attaches a tty sets it (first-run-onboarding#REQ:never-block-without-terminal).

View Source
const EnvStartFault = "OVDB_TEST_START_FAULT"

EnvStartFault is a hidden test-only variable: a server started with it set to "1" exits before readiness, so start fails with server_start_failed.

Variables

This section is empty.

Functions

func EngineName added in v0.11.0

func EngineName(id string) string

EngineName is an engine id as people read it.

func Render

func Render(err error, args []string, stdout, stderr io.Writer) bool

Render prints err when it is an envelope error and reports whether it did: the JSON document on stdout when args ask for --json, otherwise the problem pattern on stderr (first-run-onboarding#REQ:problem-pattern). main calls it before fang's own error output, so legacy commands keep theirs. args are the raw arguments, because a flag error happens before --json itself is parsed.

func StateLabel added in v0.11.0

func StateLabel(state string) string

StateLabel is a mount state as people read it.

Types

type App

type App struct {
	Version string
	Getenv  paths.Getenv // os.Getenv when nil
	// Environ lists the environment for agent detection; os.Environ when nil.
	Environ func() []string
	// TelemetryKey and TelemetryEndpoint replace the build's PostHog key and
	// endpoint (tests).
	TelemetryKey, TelemetryEndpoint string

	// Executable runs the detached server; os.Executable() when empty.
	Executable string
	// ChildEnv is appended to the detached server's environment (tests).
	ChildEnv []string
	// IsTerminal reports whether fd is a real terminal; term.IsTerminal when
	// nil. Tests inject a fake so RootRunE's TUI-vs-non-interactive branch
	// does not depend on the process's actual stdio.
	IsTerminal func(fd uintptr) bool
	// TermSize resolves the TUI's starting width and height; term.GetSize
	// on os.Stdout when nil. Tests inject a fake for the same reason.
	TermSize func() (width, height int)
	// OpenBrowser launches a URL; browser.Opener{}.Open when nil.
	OpenBrowser func(url string) error
	// Getwd is the working directory project contexts are found from;
	// os.Getwd when nil.
	Getwd func() (string, error)
	// ConsoleBuilt reports whether this binary embeds the web console and
	// TODO app; web.Built when nil.
	ConsoleBuilt func() bool
	// contains filtered or unexported fields
}

App carries what every command needs from the process.

func (*App) AddCommands

func (a *App) AddCommands(root *cobra.Command)

AddCommands registers every user-facing command on root. Internal plumbing such as `server run` hides itself in its own command group.

func (*App) DatabasesLocal added in v0.19.0

func (a *App) DatabasesLocal(list, create *cobra.Command)

DatabasesLocal makes `ovdb databases` and `ovdb databases create` use the local OVDB setup, unless --url (list) or --addr (create) explicitly asks for the remote-server compatibility path.

func (*App) FlushTelemetry added in v0.18.0

func (a *App) FlushTelemetry(ctx context.Context)

FlushTelemetry sends this command's events in one batch, bounded by telemetry.Timeout; main calls it after the command, success or failure, so output and exit code never depend on it (REQ:bounded-synchronous-sender).

func (*App) RootRunE added in v0.10.0

func (a *App) RootRunE(cmd *cobra.Command, _ []string) error

RootRunE implements first-run-onboarding#REQ:bare-ovdb-launches-tui and REQ:bare-ovdb-non-interactive: a real terminal opens the TUI on Home; anything else (a pipe, redirected stdin/stdout, or OVDB_NON_INTERACTIVE) prints the same status `ovdb status` would and exits 0 without waiting for input.

main.go registers this on root only behind OVDB_PREVIEW=1, so bare `ovdb` keeps printing today's help without the gate — REQ:preview-gate — and the existing golden test is untouched.

func (*App) Status

func (a *App) Status(cmd *cobra.Command, jsonOut bool) error

Status implements `ovdb status`: a pure read that never starts a server (first-run-onboarding#REQ:status-command).

func (*App) TUIRecorder added in v0.18.0

func (a *App) TUIRecorder(home string) *telemetry.Recorder

TUIRecorder is the TUI process's recorder: channel tui, buffering while not_asked.

func (*App) TokensLocal added in v0.19.0

func (a *App) TokensLocal(token *cobra.Command)

TokensLocal makes `ovdb token create|list|revoke` manage tokens in <OVDB home>/auth.json through the local OVDB server by default. --addr or --owner-token explicitly selects the remote-server compatibility path.

Jump to

Keyboard shortcuts

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