config

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package config loads rigo.toml and discovers the vault location.

Index

Constants

View Source
const (
	DefaultOSDir    = ".os"
	DefaultAbsDir   = ".abs"
	DefaultTrashDir = ".trash"
)

Default names of the special vault directories, overridable in rigo.toml via os_dir / abs_dir / trash_dir.

Variables

This section is empty.

Functions

func Discover

func Discover() (string, string, error)

Discover locates rigo.toml via the symlink at $XDG_CONFIG_HOME/rigo/rigo.toml (default ~/.config/rigo/rigo.toml) and derives the vault root from the symlink target. It returns the resolved config path and the vault root.

func ExpandHome added in v1.0.3

func ExpandHome(arg string) (string, error)

ExpandHome expands a leading ~ (alone, ~/, or ~\) to the user's home directory. Shells that do not expand ~ for external commands (PowerShell among them) pass it through literally, so rigo handles it itself. ~user forms pass through unchanged.

func FromFile

func FromFile(path string) (string, string, error)

FromFile derives the config path and vault root from an explicitly given rigo.toml path (the global -f flag).

Types

type Config

type Config struct {
	Dirs     []string
	Ignore   []string
	Distros  []string
	OSDir    string
	AbsDir   string
	TrashDir string
	Tags     map[string][]string
	Groups   map[string][]string
	Include  map[string][]string
	Exclude  map[string][]string
	Secrets  map[string]Secret
	Volumes  map[string]Volume
}

Config is the typed content of rigo.toml. Paths are kept as written (including any trailing slash); normalization against the vault tree happens at scan time.

func Load

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

Load reads and validates the rigo.toml at path.

type Edit

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

Edit performs format-preserving mutations on a rigo.toml: user comments, blank lines, and ordering survive a load/save round trip.

func OpenEdit

func OpenEdit(path string) (*Edit, error)

OpenEdit parses the rigo.toml at path for editing. Pass the vault-side real path (the resolved config path), not the symlink.

func (*Edit) AppendItem

func (e *Edit) AppendItem(key []string, item string) error

AppendItem appends a string item to the array at key, creating the key (and its table section) when missing. key is either a top-level array key like ["dirs"] or a table entry like ["tags", "vim"].

func (*Edit) RemoveRefs

func (e *Edit) RemoveRefs(path string) int

RemoveRefs removes every array item equal to path (modulo a trailing slash) from dirs and from every array under [tags], [include], and [exclude]. Keys whose arrays become empty are kept. It returns the number of removed items.

func (*Edit) Save

func (e *Edit) Save() error

Save writes the document back atomically (temp file + rename).

func (*Edit) SetKey

func (e *Edit) SetKey(key []string, value string) error

SetKey sets a string value at key (e.g. ["volumes", "data"] = "d"), creating the section and key as needed. An existing value is overwritten.

type Secret

type Secret struct {
	Ref  string
	Mode fs.FileMode
	OS   []string
}

Secret is one [secrets] entry: a backend reference (op:// etc.) materialized at the entry's home-relative path.

type Volume

type Volume struct {
	Default string            // drive letter; "" when only hosts map it
	Hosts   map[string]string // host or group name → drive letter
}

Volume is one [volumes] entry: a named Windows volume mapped to a drive letter, either globally (Default) or per host/group.

Jump to

Keyboard shortcuts

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