state

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package state persists the sticky "current target" across CLI invocations, keyed per browser endpoint, under $XDG_STATE_HOME.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateSession added in v0.3.0

func ValidateSession(name string) error

ValidateSession reports whether name is a well-formed session namespace. An empty name means "no session" and is valid, the same way browser.ValidateEndpoint treats an empty --endpoint as unset — so a caller can validate the flag/env/config value unconditionally without special- casing "not given".

It is a pure function (no filesystem, no Chrome) so it can run in PersistentPreRunE ahead of resolveTarget/getBrowser (a malformed --session is usage/exit 2 before anything connects) and, exported for exactly this, in internal/config's applyFile/applyEnv, where a malformed CHROME_CDP_SESSION or TOML session is dropped silently like a malformed endpoint is.

Types

type Store

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

Store holds per-endpoint CLI state under an XDG state directory.

func New

func New(key string) (*Store, error)

New returns a Store rooted at $XDG_STATE_HOME/chrome-cdp (or ~/.local/state), keyed by an endpoint identity (e.g. host:port of the debug endpoint) so distinct Chrome instances don't share a sticky target.

func (*Store) CurrentTarget

func (s *Store) CurrentTarget() string

CurrentTarget returns the sticky target spec, or "" if none is set.

func (*Store) SetCurrentTarget

func (s *Store) SetCurrentTarget(spec string) error

SetCurrentTarget persists the sticky target spec.

Jump to

Keyboard shortcuts

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