Documentation
¶
Overview ¶
Package config handles loading, saving, and querying the hrd configuration file (~/.config/hrd/config.toml by default).
Index ¶
- func DefaultPath() string
- func Save(path string, cfg Config) error
- type Config
- func (c *Config) AddRepo(name string, repo Repo)
- func (c *Config) AddRepoToGroup(name, group string)
- func (c *Config) RemoveRepo(name string)
- func (c *Config) RemoveRepoFromGroup(name, group string)
- func (c *Config) ResolveScope(names []string) ([]string, error)
- func (c *Config) ValidatedRepos(names []string) ([]string, error)
- type Group
- type Repo
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
Types ¶
type Config ¶
type Config struct {
Repos map[string]Repo `toml:"repos"`
Groups map[string]Group `toml:"-"` // derived from Repos[].Groups, not persisted
Settings Settings `toml:"settings"`
}
Config is the top-level config structure that maps directly to the TOML file.
func Load ¶
Load returns a default config when the file does not exist. The file is created on first write.
func (*Config) AddRepo ¶
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
AddRepoToGroup updates the groups cache after adding the repo.
func (*Config) RemoveRepo ¶
RemoveRepo scrubs a repo from the config and all groups.
func (*Config) RemoveRepoFromGroup ¶ added in v0.7.0
RemoveRepoFromGroup updates the groups cache after removing the repo.
func (*Config) ResolveScope ¶
ResolveScope resolves explicit CLI names/groups into repo names.
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 ¶
ActiveBackend detects and returns the active VCS backend for this repo. Returns empty string if no VCS is detected.