config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvHome    = "BRAINJAR_HOME"
	ConfigFile = "config.yaml"
	DBFile     = "brainjar.db"
)
View Source
const ConfigSchemaVersion = 1

ConfigSchemaVersion is bumped when the on-disk YAML schema changes in a non-backwards-compatible way. `Load` refuses to read unknown versions.

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath(home string) string

ConfigPath returns the absolute path to the config file inside home.

func DBPath

func DBPath(home string) string

DBPath returns the absolute path to the SQLite database inside home.

func IsNotExist

func IsNotExist(err error) bool

IsNotExist reports whether err indicates the config file is missing.

func ResolveHome

func ResolveHome(homeFlag string) (string, error)

ResolveHome returns the brainjar home directory.

Precedence, highest wins:

  1. homeFlag (the --home flag value, empty if unset)
  2. $BRAINJAR_HOME
  3. $HOME/.brainjar

func Save

func Save(home string, cfg *Config) error

Save writes cfg to <home>/config.yaml with 0o600 perms. The home dir must already exist.

Types

type Config

type Config struct {
	// SchemaVersion is the config file's schema version. Set by `init`.
	SchemaVersion int `yaml:"schema_version" koanf:"schema_version"`

	// WorkspaceID is the stable UUID of the workspace this home directory
	// is bound to. Set by `init`. Names can drift; IDs don't.
	WorkspaceID string `yaml:"workspace_id" koanf:"workspace_id"`
}

Config is the on-disk CLI configuration. One instance per home dir.

func Defaults

func Defaults() Config

Defaults returns a Config with the compiled-in default values.

func Load

func Load(home string) (*Config, error)

Load reads the config at <home>/config.yaml. Returns a wrapped os.ErrNotExist if the file is missing — callers (e.g. `init`) can detect this with errors.Is.

Jump to

Keyboard shortcuts

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