clientcfg

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package clientcfg persists client-side settings (things the CLI/TUI need that the daemon doesn't), stored at ~/.dejima/client.json. It is intentionally separate from per-island project configs and from daemon state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddProfile added in v0.6.0

func AddProfile(name, host string) error

AddProfile saves a new connection target and persists it. It is the store half of the TUI add-flow, factored out so the CLI (`dejima profile add`) and the TUI share one code path. A duplicate name is rejected so two profiles can't shadow each other in lookups.

func Save

func Save(c Config) error

Save writes the client config.

func SwitchProfile added in v0.6.0

func SwitchProfile(name string) error

SwitchProfile persists name as the active profile — the same write the TUI switcher makes. Unlike LookupProfile (ephemeral), this *does* mutate active_profile in client.json, which is the whole point of `switch` vs `-p`. The synthetic "local" clears the active profile (back to the Unix socket). An unknown name is rejected so `switch` can't leave a dangling reference.

Types

type Config

type Config struct {
	// RepoRoot is the directory the TUI repo picker scans for git repos.
	// Empty means the user hasn't chosen one yet (first-load prompt pending).
	RepoRoot string `json:"repo_root,omitempty"`

	// Profiles are saved connection targets (local + remote daemons), switchable
	// from the TUI. ActiveProfile records the last one selected.
	Profiles      []Profile `json:"profiles,omitempty"`
	ActiveProfile string    `json:"active_profile,omitempty"`

	// Editor is the CLI command for the user's preferred Remote-SSH editor
	// (e.g. "code", "cursor", "windsurf", "antigravity"). Empty means auto-detect
	// the first one on PATH. Set from the TUI settings (',').
	Editor string `json:"editor,omitempty"`
}

Config holds client-side preferences.

func Load

func Load() (Config, error)

Load reads the client config. A missing file yields a zero Config, no error.

func (Config) ActiveHost

func (c Config) ActiveHost() (host string, ok bool)

ActiveHost resolves the currently-active profile to its daemon host. ok is false when the active profile is the local socket, unset, or *dangling* — i.e. ActiveProfile names a profile that no longer exists (e.g. it was deleted while still selected). A dangling reference resolves to local rather than wedging the client on a target it can't look up.

func (Config) LookupProfile added in v0.6.0

func (c Config) LookupProfile(name string) (host string, err error)

LookupProfile resolves a profile by name to its daemon host, reading nothing but the in-memory config. The synthetic "local" name (and "") resolve to the empty host (the local Unix socket). This is the *ephemeral* lookup behind the `-p/--profile` launch flag: it never touches ActiveProfile, so selecting a profile for one invocation can't stomp the persistent choice shared by concurrent TUIs. An unknown name is an error (vs ActiveHost's silent fall-back), because an explicit `-p typo` should fail loudly, not connect somewhere unexpected.

type Profile

type Profile struct {
	Name string `json:"name"`
	Host string `json:"host,omitempty"`
}

Profile is a saved connection target. Host is "" for the local Unix socket, or "host:port" for a remote daemon reached over TCP.

Jump to

Keyboard shortcuts

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