config

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: 5 Imported by: 0

Documentation

Overview

Package config loads optional persistent defaults from a TOML file and merges them with CHROME_CDP_* environment variables into the effective global-flag defaults. Precedence, highest first: explicit flags > env > config file > built-in defaults. Cobra applies the flags; this package resolves the env > config > built-in portion and hands the result to the command tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path() string

Path returns the config file location under $XDG_CONFIG_HOME (or ~/.config).

Types

type Defaults

type Defaults struct {
	Timeout    time.Duration
	By         string
	Wait       string
	Target     string
	Port       int
	ProfileDir string
	NoLaunch   bool
	NoDaemon   bool
	JSON       bool
	NoColor    bool
}

Defaults are the effective global-flag defaults after the config file and CHROME_CDP_* env are merged over the built-in values.

func Builtin

func Builtin() Defaults

Builtin returns the hard-coded defaults used when neither the config file nor the environment sets a value.

func FromEnv

func FromEnv() Defaults

FromEnv returns the built-in defaults overlaid with CHROME_CDP_* env vars only (no config file). The daemon subprocess uses it: the parent already folded the config file into the environment it hands down, so parsing stays in one place.

func Resolve

func Resolve() (Defaults, error)

Resolve returns the effective flag defaults from the real config path and environment. A malformed config yields a non-nil error but still-usable defaults (built-ins plus env), so a bad file never bricks the CLI.

func ResolveFrom

func ResolveFrom(path string, getenv func(string) string) (Defaults, error)

ResolveFrom is Resolve with the config path and environment injected, for testing. It overlays the config file, then env, onto the built-in defaults.

Jump to

Keyboard shortcuts

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