config

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config handles configuration loading from CLI flags, environment variables, and TOML files. CRC: crc-Config.md Spec: deployment.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Server  ServerConfig  `toml:"server"`
	Lua     LuaConfig     `toml:"lua"`
	Session SessionConfig `toml:"session"`
	Logging LoggingConfig `toml:"logging"`
}

Config holds all configuration settings for the UI server.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with all default values.

func Load

func Load(args []string) (*Config, error)

Load loads configuration from CLI flags, environment variables, and TOML file. Priority: CLI flags > env vars > TOML file > defaults

func (*Config) Log

func (c *Config) Log(level int, format string, args ...interface{})

Log logs a message if the configured verbosity level is greater than or equal to the required level.

func (*Config) Verbosity

func (c *Config) Verbosity() int

Verbosity returns the configured verbosity level (0-3).

type Duration

type Duration time.Duration

Duration is a time.Duration that can be unmarshaled from TOML strings.

func (Duration) Duration

func (d Duration) Duration() time.Duration

Duration returns the underlying time.Duration.

func (Duration) String

func (d Duration) String() string

String returns the duration as a string.

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler for Duration.

type LoggingConfig

type LoggingConfig struct {
	Level     string `toml:"level"`     // "debug", "info", "warn", "error"
	Verbosity int    `toml:"verbosity"` // 0=none, 1=connections, 2=messages, 3=variables, 4=values
}

LoggingConfig holds logging settings.

type LuaConfig

type LuaConfig struct {
	Enabled bool   `toml:"enabled"`
	Path    string `toml:"path"`
	Hotload bool   `toml:"hotload"` // Watch lua directory for changes
}

LuaConfig holds Lua runtime settings.

type ServerConfig

type ServerConfig struct {
	Host   string `toml:"host"`
	Port   int    `toml:"port"`
	Socket string `toml:"socket"`
	Dir    string `toml:"-"` // Custom site directory (CLI only, not in config file)
}

ServerConfig holds server-related settings.

type SessionConfig

type SessionConfig struct {
	Timeout Duration `toml:"timeout"` // Session expiration (0 = never)
}

SessionConfig holds session-related settings.

Jump to

Keyboard shortcuts

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