config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config handles loading, saving, and querying the hrd configuration file (~/.config/hrd/config.toml by default).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the platform config path for the hrd config file.

func Save

func Save(path string, cfg Config) (err error)

Save writes cfg to path, creating parent directories as needed.

Types

type Config

type Config struct {
	Repos    map[string]Repo  `toml:"repos"`
	Groups   map[string]Group `toml:"groups"`
	Context  Context          `toml:"context"`
	Settings Settings         `toml:"settings"`
}

Config is the top-level config structure that maps directly to the TOML file.

func Load

func Load(path string) (Config, error)

Load reads the config file at path. If the file does not exist a default config is returned without error — the file is created on first write.

func (*Config) AddGroup

func (c *Config) AddGroup(name string, repos []string) error

AddGroup creates or replaces a group.

func (*Config) AddRepo

func (c *Config) AddRepo(name string, repo Repo)

AddRepo adds or updates a repo entry. The name is derived from the directory base name unless it would conflict, in which case the caller should provide an explicit name.

func (*Config) RemoveRepo

func (c *Config) RemoveRepo(name string)

RemoveRepo removes a repo and scrubs it from all groups.

func (*Config) ResolveScope

func (c *Config) ResolveScope(names []string) ([]string, error)

ResolveScope returns the list of repo names to operate on given an explicit set of names/group passed on the CLI.

type Context

type Context struct {
	// Current is a group name, or empty to mean all repos.
	Current string `toml:"current,omitempty"`
}

Context holds the active scope used when no repos/group is specified.

type Group

type Group struct {
	Repos []string `toml:"repos"`
}

Group is a named collection of repo names.

type Repo

type Repo struct {
	// Path is the absolute path to the repository root.
	Path string `toml:"path"`

	// Backends holds all detected VCS backends at this path.
	// The first element is the active backend.
	Backends []string `toml:"backends"`
}

Repo represents a single tracked repository.

func (Repo) ActiveBackend

func (r Repo) ActiveBackend() string

ActiveBackend returns the first configured backend for this repo. If no backends are configured, returns empty string.

type Settings

type Settings struct {
	// Concurrency caps the number of parallel subprocess invocations.
	Concurrency int `toml:"concurrency"`
}

Settings holds global tunables.

Jump to

Keyboard shortcuts

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