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
- func EngineName(id string) string
- func Render(err error, args []string, stdout, stderr io.Writer) bool
- func StateLabel(state string) string
- type App
- func (a *App) AddCommands(root *cobra.Command)
- func (a *App) DatabasesLocal(list, create *cobra.Command)
- func (a *App) FlushTelemetry(ctx context.Context)
- func (a *App) RootRunE(cmd *cobra.Command, _ []string) error
- func (a *App) Status(cmd *cobra.Command, jsonOut bool) error
- func (a *App) TUIRecorder(home string) *telemetry.Recorder
- func (a *App) TokensLocal(token *cobra.Command)
Constants ¶
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).
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
EngineName is an engine id as people read it.
func Render ¶
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
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 ¶
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
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
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
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 ¶
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
TUIRecorder is the TUI process's recorder: channel tui, buffering while not_asked.
func (*App) TokensLocal ¶ added in v0.19.0
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.