cli

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 38 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 the preview `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 new command is hidden unless OVDB_PREVIEW=1, 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 the new commands on root, hidden without the gate.

func (*App) DatabasesPreview added in v0.11.0

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

DatabasesPreview adds the preview behaviour to the legacy `ovdb databases` and `ovdb databases create` commands: with OVDB_PREVIEW=1 they use the local OVDB server, unless --url (list) or --addr (create) asks for today's behaviour (database-setup-and-providers#REQ:list-and-remove, REQ:legacy-create-compatible). Without the gate nothing changes, not even the flags help shows.

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 is the preview `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) TokensPreview added in v0.13.0

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

TokensPreview adds the preview behaviour to the legacy `ovdb token create`, `list` and `revoke`: with OVDB_PREVIEW=1 they manage the tokens in <OVDB home>/auth.json through the local OVDB server with the instance secret, starting it when needed, unless --addr or --owner-token asks for today's remote-server behaviour (local-server-and-web-console#REQ:tokens-against-local-server). Without the gate nothing changes, not even the flags help shows.

Jump to

Keyboard shortcuts

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