config

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config loads nt's optional config file, $NT_DIR/config.toml. It is a deliberately tiny TOML subset — [section] headers and `key = value` lines with string / int / bool values — so nt keeps its zero-runtime-dependency, plain- text ethos (no TOML library). A missing or partial file is never an error; unset keys keep their zero value and callers fall back to built-in defaults.

Recognized keys (all optional):

[defaults]
priority    = "high"        # default --pri for `nt add`
source      = "cli"         # default --source
agenda_days = 7             # default horizon for `nt agenda`
editor      = "nvim"        # overrides $EDITOR for `nt edit`

[web]
port = 4321                 # default `nt web` port
host = "127.0.0.1"          # default bind address

[tui]
theme = "auto"              # auto | light | dark

[decay]
lesson   = "180d"           # default --half-life stamped on new notes of that
decision = "1y"             # kind when none is given (Nd/Nw/Nm/Ny or "none").
ref      = "270d"           # rule/memory accept a value too, but pinned
                            # knowledge usually shouldn't decay — leave them unset.

Index

Constants

View Source
const FileName = "config.toml"

FileName is the config file's basename within $NT_DIR.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DefaultPriority string // [defaults] priority
	DefaultSource   string // [defaults] source
	AgendaDays      int    // [defaults] agenda_days
	Editor          string // [defaults] editor
	WebPort         int    // [web] port
	WebHost         string // [web] host
	WebDayBudget    int    // [web] day_budget_minutes — Today capacity bar budget (0 = default 360)
	TUITheme        string // [tui] theme (auto|light|dark)
	// DecayDefaults maps a note kind (lesson|decision|ref|rule|memory) to the
	// half-life stamped on NEW notes of that kind when the caller gives none —
	// per-kind decay policy without per-note judgment. Values are stored raw;
	// consumers validate with note.ParseHalfLife and skip what doesn't parse
	// (`nt doctor` reports the typo). nil when the [decay] section is absent.
	DecayDefaults map[string]string // [decay] <kind> = "180d"
}

Config is the parsed config. Zero values mean "unset" — callers OR them with their existing defaults.

func Load

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

Load reads $NT_DIR/config.toml. A missing file returns an empty Config and no error. Parse errors in individual lines are skipped, not fatal — a typo in one key never stops nt from running.

Jump to

Keyboard shortcuts

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