config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config stores a few user defaults so power users stop retyping the same flags. It is a small JSON file (config.json) under cct's config dir; it holds only non-secret preferences (which agent to act on, where the homes are, a default app port) and never anything sensitive. Every value it provides is just a default: an explicit flag always wins, so the file can be absent.

Index

Constants

View Source
const FileName = "config.json"

FileName is the config file's name within the config dir.

Variables

View Source
var Keys = []string{"tool", "codex-home", "claude-home", "port"}

Keys lists the settable keys in a stable, display order.

Functions

func FilePath

func FilePath(dir string) string

FilePath returns the config file path within dir.

Types

type Config

type Config struct {
	Tool       string `json:"tool,omitempty"`        // codex | claude
	CodexHome  string `json:"codex_home,omitempty"`  // default --codex-home
	ClaudeHome string `json:"claude_home,omitempty"` // default --claude-home
	Port       int    `json:"port,omitempty"`        // default app port
}

Config is the set of user defaults. Empty fields mean "no default set".

func Load

func Load(dir string) (Config, error)

Load reads the config from dir. A missing file is not an error: it yields a zero Config so callers can treat "no config" and "empty config" alike.

func (Config) Entries

func (c Config) Entries() [][2]string

Entries returns the configured key/value pairs in Keys order, omitting unset keys, for display by `cct config list`.

func (Config) Get

func (c Config) Get(key string) (string, error)

Get returns the string form of a key's value (empty when unset).

func (Config) Save

func (c Config) Save(dir string) error

Save writes the config to dir (0600), creating the directory if needed.

func (*Config) Set

func (c *Config) Set(key, value string) error

Set validates and applies a key/value pair. An empty value clears the key.

Jump to

Keyboard shortcuts

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