Documentation
¶
Overview ¶
Package config handles the application configuration for sbctl. It supports loading and saving configuration in JSON format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigPath ¶
ConfigPath returns the full path to the config.json file. It resolves the user's home directory or uses SBCTL_HOME if set.
func GetConfigDir ¶
GetConfigDir returns the default directory for sbctl configuration. Usually ~/.sbctl, but can be overridden by the SBCTL_HOME environment variable.
func SaveConfig ¶
SaveConfig persists the current configuration to the default path. It creates the configuration directory if it does not exist.
func SaveToPath ¶
SaveToPath persists the configuration to a specific path.
Types ¶
type Config ¶
type Config struct {
Gog GogConfig `json:"gog"`
GDrive GDriveConfig `json:"gdrive"`
Service ServiceConfig `json:"service"`
DB DBConfig `json:"db"`
Debug string `json:"debug"` // Log level (DEBUG, INFO, WARN, ERROR)
}
Config is the root configuration structure for sbctl.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config struct with sensible default values. Sync interval is set to 6h, MCP port to 8080, and DB path to ~/.sbctl/sbctl.db.
func LoadConfig ¶
LoadConfig attempts to load the configuration from the default path. If the file doesn't exist, it returns the default configuration.
func LoadFromPath ¶
LoadFromPath attempts to load the configuration from a specific path. If the file does not exist, it returns the default configuration.
func (*Config) GetValue ¶
GetValue returns the string representation of a configuration value by its key. Keys are dot-separated (e.g., "gdrive.account").
func (*Config) SetValue ¶
SetValue updates a configuration value by its key. It handles type conversion for integers and string slices (comma-separated).
func (*Config) ValidateAccount ¶
ValidateAccount checks if the mandatory default Google account is configured.
type DBConfig ¶
type DBConfig struct {
Path string `json:"path"` // Local path to the SQLite database
}
DBConfig holds database connection settings.
type GDriveConfig ¶
type GDriveConfig struct {
Include []string `json:"include"` // Folders to include in sync
Exclude []string `json:"exclude"` // Folders to exclude from sync
SheetsID string `json:"sheets_id"` // ID of the Google Sheets index
SbctlFolderID string `json:"sbctl_folder_id"` // ID of the sbctl folder in GDrive
TempDir string `json:"temp_dir"` // Local path for temporary files (e.g., OCR)
}
GDriveConfig holds Google Drive specific settings.
type GogConfig ¶
type GogConfig struct {
Account struct {
Default string `json:"default"` // Default Google account email
} `json:"account"`
Accounts []string `json:"accounts"` // List of discovered accounts
}
GogConfig holds settings for the gog CLI wrapper.
type ServiceConfig ¶
type ServiceConfig struct {
SyncInterval string `json:"sync_interval"` // Interval between syncs (e.g., "6h")
MCPPort int `json:"mcp_port"` // Port for the MCP server
}
ServiceConfig holds daemon and worker scheduling settings.