config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config locates Nicely's folders and reads the shared and local config files, as the Configuration section of contract.md defines them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(p Paths) (Config, []Key, error)

Load reads the shared file, then the local file over it. A missing file is not an error. A table merges key by key across the files, and any other value, such as a list, replaces the one below it. Unknown keys come back for the CONFIG_UNKNOWN_KEY warning, so an older ncly reads a newer config.

Types

type Config

type Config struct {
	Lang string `toml:"lang"`
}

Config holds the keys that this version of ncly knows. A zero value means the default applies.

type InvalidError

type InvalidError struct {
	File string
	Line int
	Err  error
}

InvalidError reports a config file with a syntax error or a value of the wrong type. Line is 0 when the parser does not say where.

func (*InvalidError) Error

func (e *InvalidError) Error() string

func (*InvalidError) Unwrap

func (e *InvalidError) Unwrap() error

type Key

type Key struct {
	File string
	Name string
}

Key is a key of a config file that this version of ncly does not know.

type Paths

type Paths struct {
	// Shared is config.toml, the setup the user wants on every machine.
	Shared string
	// Local is config.local.toml, beside Shared, for this machine only.
	Local string
	Data  string
	State string
	Cache string
}

Paths locates Nicely's files and folders on this machine.

func Locate

func Locate(home string, lookupEnv func(string) (string, bool)) Paths

Locate resolves the paths from home and the environment. An XDG variable counts only when it holds an absolute path, as the XDG specification asks. NCLY_CONFIG names another shared file, and the local file moves beside it. Without an absolute home or XDG variable, default paths stay empty instead of resolving from the current folder.

Jump to

Keyboard shortcuts

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