config

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 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 provides the single source of truth for arc CLI and server settings. Settings are stored in TOML format at ~/.arc/config.toml.

Index

Constants

View Source
const DefaultServerPort = 7432

DefaultServerPort is the built-in default port for the arc server.

Variables

View Source
var ValidChannels = []string{"stable", "rc", "nightly"}

ValidChannels lists the allowed values for updates.channel.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns ~/.arc/config.toml.

func LegacyJSONPath

func LegacyJSONPath() string

LegacyJSONPath returns ~/.arc/cli-config.json (the pre-TOML location).

func RequiresRestart

func RequiresRestart() []string

RequiresRestart returns dotted keys whose changes don't take effect in a running arc-server until the server restarts. Used by the API + web UI to surface a "requires restart" warning.

func Save

func Save(path string, cfg *Config) error

Save atomically writes cfg to path as TOML with 0600 permissions. The write is atomic: it creates a temp file, fsyncs, then renames over path. The config is validated before writing; invalid configs return an error.

func Validate

func Validate(cfg *Config) error

Validate checks each field in cfg and returns a ValidationError describing all invalid fields, or nil if the config is fully valid.

Types

type CLIConfig

type CLIConfig struct {
	Server string `toml:"server" json:"server"`
}

CLIConfig holds settings the arc CLI uses to reach the server.

type Config

type Config struct {
	CLI     CLIConfig     `toml:"cli"     json:"cli"`
	Server  ServerConfig  `toml:"server"  json:"server"`
	Share   ShareConfig   `toml:"share"   json:"share"`
	Updates UpdatesConfig `toml:"updates" json:"updates"`
}

Config is the full arc configuration document.

func Default

func Default() *Config

Default returns a Config populated with built-in defaults.

func Load

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

Load reads the TOML config from path. If path is missing but the legacy cli-config.json exists in the same directory, Load migrates JSON → TOML, renames the legacy file to *.bak, and prints a one-line stderr notice. If neither exists, Load writes Default() to path and returns it. Missing fields are filled from Default(). The returned Config is validated; an invalid file returns a non-nil error.

type ServerConfig

type ServerConfig struct {
	Port   int    `toml:"port"    json:"port"`
	DBPath string `toml:"db_path" json:"db_path"`
}

ServerConfig holds settings the arc server uses for its own runtime.

func (ServerConfig) ResolvedDBPath

func (s ServerConfig) ResolvedDBPath() string

ResolvedDBPath returns DBPath with a leading ~ expanded to the user's home directory. Use this when you need a real filesystem path (e.g., opening the SQLite database). Do NOT call this before writing DBPath back to TOML — the raw value (which may contain ~) should be stored as-is for portability.

type ShareConfig

type ShareConfig struct {
	Author string `toml:"author" json:"author"`
	Server string `toml:"server" json:"server"`
}

ShareConfig holds defaults for `arc share` and the web share UI.

type Store

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

Store wraps an atomically-swappable *Config. The arc server holds one Store and reads through Load() so that a future Reload() can hot-swap without mutating consumers. Callers must treat the returned *Config as read-only.

func NewStore

func NewStore(cfg *Config) *Store

NewStore creates a Store pre-loaded with cfg.

func (*Store) Load

func (s *Store) Load() *Config

Load returns the current config snapshot.

func (*Store) Swap

func (s *Store) Swap(cfg *Config) *Config

Swap atomically replaces the active config and returns the previous one.

type UpdatesConfig

type UpdatesConfig struct {
	Channel string `toml:"channel" json:"channel"`
}

UpdatesConfig holds update-channel settings for `arc self`.

type ValidationError

type ValidationError map[string]string

ValidationError maps dotted-key to error message.

func (ValidationError) Error

func (v ValidationError) Error() string

Error returns a sorted, semicolon-separated list of all validation failures.

Jump to

Keyboard shortcuts

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