Help us shape the future of Go! Take the 2026 Go Developer Survey

globalconfig

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the config file location, respecting XDG_CONFIG_HOME.

Types

type Config

type Config struct {
	Dotfiles  DotfilesConfig  `toml:"dotfiles"`
	Plugins   PluginsConfig   `toml:"plugins"`
	Workspace WorkspaceConfig `toml:"workspace"`
}

Config holds user-level crib settings from ~/.config/crib/config.toml.

func Load

func Load() (*Config, error)

Load reads the global config from the default path. Returns a zero Config (not an error) if the file does not exist.

func LoadFrom

func LoadFrom(path string) (*Config, error)

LoadFrom reads the global config from the given path. Returns a zero Config (not an error) if the file does not exist.

type CribRC added in v0.9.0

type CribRC struct {
	// Config sets the devcontainer config directory (equivalent to -C/--config).
	Config string `toml:"config"`

	// Cache lists package cache providers. Accepts a TOML array or a
	// comma-separated string for backward compatibility with the pre-TOML
	// .cribrc format.
	Cache StringList `toml:"cache"`

	// Dotfiles overrides global dotfiles settings and carries the kill switch.
	Dotfiles DotfilesRC `toml:"dotfiles"`

	// Plugins disables bundled plugins for the current project.
	Plugins PluginsRC `toml:"plugins"`

	// Workspace is the per-project workspace section (env, mounts, run_args).
	Workspace WorkspaceConfig `toml:"workspace"`
}

CribRC holds values loaded from a per-project .cribrc file.

func LoadCribRC added in v0.9.0

func LoadCribRC(path string) (*CribRC, error)

LoadCribRC reads a .cribrc file at the given path. Returns a zero CribRC (not an error) if the file does not exist.

The file is pre-processed before TOML decoding to coerce bare string values (the pre-TOML .cribrc format) into quoted TOML strings. This preserves backward compatibility with files written in the old format, e.g.:

cache = npm, pip, go          → cache = "npm, pip, go"
plugins.disable = ssh         → plugins.disable = "ssh"
dotfiles.repository = git@…   → dotfiles.repository = "git@…"

Lines that are already valid TOML (quoted strings, arrays, inline tables, booleans) are passed through unchanged.

type DotfilesConfig

type DotfilesConfig struct {
	Repository     string `toml:"repository"`
	TargetPath     string `toml:"targetPath"`
	InstallCommand string `toml:"installCommand"`
}

DotfilesConfig configures dotfiles repository cloning and installation.

type DotfilesRC added in v0.9.0

type DotfilesRC struct {
	Disabled       bool
	Repository     string `toml:"repository"`
	TargetPath     string `toml:"targetPath"`
	InstallCommand string `toml:"installCommand"`
}

DotfilesRC mirrors DotfilesConfig plus a `dotfiles = "false"` kill switch handled in UnmarshalTOML.

func (*DotfilesRC) UnmarshalTOML added in v0.9.0

func (d *DotfilesRC) UnmarshalTOML(v any) error

UnmarshalTOML accepts either a nested table (dotfiles.repository, etc.) or a legacy kill switch: the boolean `dotfiles = false` (pre-TOML .cribrc) and the quoted string `dotfiles = "false"` both set Disabled. Table decoding is delegated to the tagged struct so field names stay in one place.

type PluginsConfig added in v0.9.0

type PluginsConfig struct {
	Disable    []string `toml:"disable"`
	DisableAll bool     `toml:"disable_all"`
}

PluginsConfig disables bundled plugins globally. Disable lists specific plugins by name; DisableAll is a kill switch that skips plugin registration entirely.

type PluginsRC added in v0.9.0

type PluginsRC struct {
	DisableAll bool
	Disable    StringList `toml:"disable"`
}

PluginsRC mirrors PluginsConfig but also honors a `plugins = "false"` kill switch handled in UnmarshalTOML.

func (*PluginsRC) UnmarshalTOML added in v0.9.0

func (p *PluginsRC) UnmarshalTOML(v any) error

UnmarshalTOML accepts either a nested table (plugins.disable, etc.) or a legacy kill switch: the boolean `plugins = false` (pre-TOML .cribrc) and the quoted string `plugins = "false"` both set DisableAll. Table decoding is delegated to the tagged struct so field names stay in one place.

type StringList added in v0.9.0

type StringList []string

StringList accepts either a TOML array of strings or a single comma-separated string. It trims each entry and drops empties. The comma-separated form exists for backward compatibility with the pre-TOML .cribrc format (e.g. `plugins.disable = ssh, dotfiles`).

func (*StringList) UnmarshalTOML added in v0.9.0

func (s *StringList) UnmarshalTOML(v any) error

UnmarshalTOML implements toml.Unmarshaler.

type WorkspaceConfig added in v0.9.0

type WorkspaceConfig struct {
	Env     map[string]string `toml:"env"`
	Mounts  []string          `toml:"mount"`
	RunArgs []string          `toml:"run_args"`
}

WorkspaceConfig is applied to every container on top of project-level configuration. Project values win on key conflicts.

Jump to

Keyboard shortcuts

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