Documentation
¶
Overview ¶
Package config manages CLI configuration with layered resolution.
Index ¶
- func AllKeyNames() []string
- func CacheDir() string
- func ConfigDir() string
- func ConfigFilePath() string
- func EnvOverrides() map[string]string
- func GetDotKey(cfg *Config, key string) (string, bool)
- func KeysByCategory() map[string][]KeyMeta
- func ParseDuration(s string) (time.Duration, error)
- func Save(cfg *Config) error
- func SetDotKey(cfg *Config, key, value string) error
- func ToFlatMap(cfg *Config) map[string]string
- func UnsetDotKey(cfg *Config, key string) error
- func Validate(cfg *Config) error
- func ValidateKeyValue(key, value string) error
- type BackupConfig
- type Config
- type HTTPConfig
- type KeyMeta
- type LogConfig
- type OutputConfig
- type RetryConfig
- type ScanConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶
func CacheDir() string
CacheDir returns the cache directory path (XDG_CACHE_HOME/microcms).
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the config directory path (XDG_CONFIG_HOME/microcms).
func EnvOverrides ¶
EnvOverrides reads MICROCMS_* environment variables and returns config overrides.
func KeysByCategory ¶
KeysByCategory groups keys by their top-level category.
func ParseDuration ¶
ParseDuration parses a duration string, returning an error with context.
func Save ¶
Save writes config to config.json atomically. Empty nested objects are removed to keep the file clean.
func UnsetDotKey ¶
UnsetDotKey removes a value from config by dot-notation key.
func ValidateKeyValue ¶
ValidateKeyValue validates a single key-value pair.
Types ¶
type BackupConfig ¶
type BackupConfig struct {
Parallelism *int `json:"parallelism,omitempty"`
IncludeSchema *bool `json:"includeSchema,omitempty"`
IncludeManagementMeta *bool `json:"includeManagementMeta,omitempty"`
DownloadMedia *bool `json:"downloadMedia,omitempty"`
Resume *bool `json:"resume,omitempty"`
FailFast *bool `json:"failFast,omitempty"`
}
type Config ¶
type Config struct {
ActiveService string `json:"activeService,omitempty"`
HTTP HTTPConfig `json:"http,omitempty"`
Output OutputConfig `json:"output,omitempty"`
Scan ScanConfig `json:"scan,omitempty"`
Backup BackupConfig `json:"backup,omitempty"`
Log LogConfig `json:"log,omitempty"`
}
Config represents the full CLI configuration.
type HTTPConfig ¶
type HTTPConfig struct {
Timeout string `json:"timeout,omitempty"`
Retry RetryConfig `json:"retry,omitempty"`
}
type KeyMeta ¶
type KeyMeta struct {
Key string
Type string // "string", "bool", "int", "duration", "enum", "[]int"
EnvVar string
Description string
Allowed []string // For enum types
}
KeyMeta describes a config key with its type, env var, and description.
type OutputConfig ¶
type RetryConfig ¶
type RetryConfig struct {
Enabled *bool `json:"enabled,omitempty"`
MaxAttempts *int `json:"maxAttempts,omitempty"`
BaseInterval string `json:"baseInterval,omitempty"`
MaxInterval string `json:"maxInterval,omitempty"`
Jitter *bool `json:"jitter,omitempty"`
Policy string `json:"policy,omitempty"`
RetryOn []int `json:"retryOn,omitempty"`
}