cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package cli builds chrome-cdp's cobra command tree and translates every command into the uniform result envelope + exit-code contract.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set at build time via -ldflags.

Functions

This section is empty.

Types

type App

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

App carries per-invocation state: the Browser port, output streams, parsed global flags, and the resulting exit code.

func New

func New(b chrome.Browser, out, errw io.Writer) *App

New builds an App around a Browser and output streams. The --timeout flag's default is the single source of truth for the timeout (see newRoot).

func (*App) Close

func (a *App) Close()

Close tears down a Browser that this App lazily connected (no-op for an injected Browser, e.g. in tests).

func (*App) Execute

func (a *App) Execute(args ...string) int

Execute runs the command tree for args and returns the process exit code.

func (*App) WithConnector

func (a *App) WithConnector(fn func(ctx context.Context, o ConnOpts) (chrome.Browser, error)) *App

WithConnector wires a lazy Browser connector (used by main()); it is invoked only when a command actually needs Chrome.

func (*App) WithDaemonCtl

func (a *App) WithDaemonCtl(start, stop, status func(ConnOpts) (map[string]any, error)) *App

WithDaemonCtl wires the daemon start/stop/status operations (used by main()).

func (*App) WithDefaults

func (a *App) WithDefaults(d config.Defaults) *App

WithDefaults overrides the built-in flag defaults with values resolved from the config file + environment (used by main()); tests keep the built-ins.

func (*App) WithInput

func (a *App) WithInput(r io.Reader) *App

WithInput overrides the stdin reader used by `session` (used by tests).

func (*App) WithStickyTarget

func (a *App) WithStickyTarget(get func(ConnOpts) string, set func(ConnOpts, string) error) *App

WithStickyTarget wires the persisted current-target store (used by main()). get/set take the connection options so the store is keyed per endpoint.

type ConnOpts

type ConnOpts struct {
	NoLaunch   bool
	ProfileDir string
	Port       int
	NoDaemon   bool
}

ConnOpts are the connection-related flags handed to the connector.

Jump to

Keyboard shortcuts

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