config

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config finds and parses rotari's config files.

A config file is config.yaml, config.toml, or config.json in the global config directory, a base directory, or a project directory. This package owns where those files are looked for, which scope applies, and how each format is parsed. What the keys mean (CLI option defaults) and the config template belong to cmd/rotari.

Index

Constants

View Source
const WorkspaceFile = ".rotari.toml"

Variables

View Source
var Warnf = func(format string, args ...any) {
	fmt.Fprintf(os.Stderr, format+"\n", args...)
}

Warnf reports a config file that cannot be inspected, read, or parsed; such a file is skipped or treated as empty. It writes to stderr unless replaced.

Functions

func EffectivePath

func EffectivePath(baseDir, projectName string) string

EffectivePath returns the legacy single-file config location. New callers should use Load to enumerate and merge all scopes.

func FilePaths

func FilePaths(directory string) []string

FilePaths returns the config files that exist in directory.

func GlobalPath

func GlobalPath() string

GlobalPath returns the global config file, or "" when there is none.

func HomeDir

func HomeDir() (string, error)

HomeDir returns the global config directory: $XDG_CONFIG_HOME/rotari, or ~/.config/rotari.

func ListPaths

func ListPaths(baseDir, projectName string, additionalNames ...string) (common []string, projects map[string][]string)

ListPaths returns every config file found across all scopes for `config --list`. additionalNames are other config filenames to include, such as notifications.toml. Unlike PathsForRun, it does not stop at the first scope that has files: --list is meant to show the user everything, not just the one scope that would take effect.

func LoadFile

func LoadFile(directory string) (map[string]any, error)

LoadFile parses the config file in directory, or returns an empty config when there is none. More than one config file there is an error.

func LoadPath

func LoadPath(path string) (map[string]any, error)

LoadPath parses the config file at path.

func Marshal

func Marshal(values map[string]any) ([]byte, error)

Marshal produces canonical TOML from file values only.

func Merge

func Merge(lower, higher map[string]any) map[string]any

Merge makes an independent deep copy. Maps recurse, arrays replace, and null is unspecified; false, zero and empty strings are retained.

func Parse

func Parse(path string, data []byte) (map[string]any, error)

Parse parses config data in the format that path's extension names.

func PathsForRun

func PathsForRun(baseDir, projectName string) []string

PathsForRun preserves legacy single-scope lookup for historical records: project, then baseDir, then global. New runs use Loaded.Snapshot instead.

func Validate

func Validate(scope, path string, values map[string]any) error

Validate prevents location cycles, including command-specific location keys.

Types

type Loaded

type Loaded struct {
	Values  map[string]any
	Sources []Source
}

Loaded holds file values captured once, independently of runtime overrides.

func Load

func Load(cwd, baseDir, projectName string) (Loaded, error)

Load reads all ordinary scopes; cwd is explicitly supplied by the caller. A Web server captures it at startup and never substitutes a job's cwd.

func LoadScope

func LoadScope(scope, directory string) (Loaded, error)

LoadScope loads at most one file, failing on invalid discovered files.

func (*Loaded) Add

func (loaded *Loaded) Add(layer Loaded)

func (Loaded) Snapshot

func (loaded Loaded) Snapshot() (*model.FileConfigSnapshot, error)

type Source

type Source = model.ConfigSource

Source identifies a real configuration file, not a synthesized view.

Jump to

Keyboard shortcuts

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