config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 5 Imported by: 0

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

func ConfigPath() (string, error)

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

func GetConfigDir() (string, error)

GetConfigDir returns the default directory for sbctl configuration. Usually ~/.sbctl, but can be overridden by the SBCTL_HOME environment variable.

func SaveConfig

func SaveConfig(cfg *Config) error

SaveConfig persists the current configuration to the default path. It creates the configuration directory if it does not exist.

func SaveToPath

func SaveToPath(cfg *Config, path string) error

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

func LoadConfig() (*Config, error)

LoadConfig attempts to load the configuration from the default path. If the file doesn't exist, it returns the default configuration.

func LoadFromPath

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

LoadFromPath attempts to load the configuration from a specific path. If the file does not exist, it returns the default configuration.

func (*Config) GetValue

func (c *Config) GetValue(key string) (string, error)

GetValue returns the string representation of a configuration value by its key. Keys are dot-separated (e.g., "gdrive.account").

func (*Config) SetValue

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

SetValue updates a configuration value by its key. It handles type conversion for integers and string slices (comma-separated).

func (*Config) ValidateAccount

func (c *Config) ValidateAccount() error

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.

Jump to

Keyboard shortcuts

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