config

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 8 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

func Save

func Save(path string, cfg Config) 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:"-"` // derived from Repos[].Groups, not persisted

	// Aliases maps user-defined command names to their expansion in the
	// unified command grammar (see internal/cmdspec): "pull --rebase"
	// routes per-repo, "git ..."/"jj ..." to that backend, "!..." or
	// "sh ..." to the shell.
	Aliases map[string]string `toml:"aliases,omitempty"`

	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 returns a default config when the file does not exist. The file is created on first write.

func (*Config) AddRepo

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

AddRepo derives the name from the directory base name unless it would conflict, in which case the caller should provide an explicit name.

func (*Config) AddRepoToGroup added in v0.7.0

func (c *Config) AddRepoToGroup(name, group string)

AddRepoToGroup updates the groups cache after adding the repo.

func (*Config) RemoveRepo

func (c *Config) RemoveRepo(name string)

RemoveRepo scrubs a repo from the config and all groups.

func (*Config) RemoveRepoFromGroup added in v0.7.0

func (c *Config) RemoveRepoFromGroup(name, group string)

RemoveRepoFromGroup updates the groups cache after removing the repo.

func (*Config) ResolveScope

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

ResolveScope resolves explicit CLI names/groups into repo names. Each name may be a repo or a group (with or without the "@" prefix); groups are expanded inline. Duplicates are removed, preserving the order of first appearance. Unknown names are an error.

type Group

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

type Repo

type Repo struct {
	// Path is the absolute path to the repository root.
	Path   string   `toml:"path"`
	Groups []string `toml:"groups"`
}

Repo represents a single tracked repository.

func (Repo) ActiveBackend

func (r Repo) ActiveBackend() string

ActiveBackend detects and returns the active VCS backend for this repo. Returns empty string if no VCS is detected.

type Settings

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

Jump to

Keyboard shortcuts

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