userconfig

package
v1.135.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package userconfig stores bitbottle user preferences in ~/.config/bitbottle/config.yml.

This is intentionally distinct from internal/config (which manages auth state in hosts.yml). User preferences cover editor/pager/browser/git_protocol/prompt and may be scoped per-host.

Index

Constants

This section is empty.

Variables

View Source
var AllowedKeys = []string{
	"editor",
	"pager",
	"browser",
	"git_protocol",
	"prompt",
}

AllowedKeys is the set of keys writable via `bitbottle config set`. This allowlist ensures users get immediate feedback on typos rather than silently writing a key the CLI never reads back.

View Source
var PerHostKeys = []string{
	"git_protocol",
}

Functions

This section is empty.

Types

type Config

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

Config is a thread-safe handle to the user preferences file.

func New

func New(dir string) *Config

New constructs a Config rooted at dir.

func (*Config) Get

func (c *Config) Get(key, host string) (string, bool)

Get returns (value, true) when key is set. Per-host lookup falls back to the global value when no host-specific override exists.

func (*Config) List

func (c *Config) List() []Entry

List returns all set keys in deterministic order: globals (sorted), then per-host entries (sorted by host, then by key).

func (*Config) Load

func (c *Config) Load() error

Load reads config.yml. A missing file is treated as empty config.

func (*Config) Save

func (c *Config) Save() error

Save writes config.yml atomically (temp file + rename).

func (*Config) Set

func (c *Config) Set(key, value, host string) error

Set records value under key, optionally scoped to a specific host.

type Entry

type Entry struct {
	Key   string
	Value string
	Host  string // empty = global scope
}

Jump to

Keyboard shortcuts

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