Documentation
¶
Overview ¶
Package config provides configuration management for LeapSQL CLI.
This package provides CLI-specific configuration fields and functionality. Shared types (TargetConfig, LintConfig, DocsConfig, RuleOptions) are in pkg/core.
Index ¶
- Constants
- func DefaultSchemaForType(dbType string) string
- func GetConfigFileUsed() string
- func GetLogger(ctx context.Context) *slog.Logger
- func LoggerKey() interface{}
- func MergeTargetConfig(base, override *core.TargetConfig) *core.TargetConfig
- func ResetConfig()
- type Config
- type EnvConfig
- type UIConfig
Constants ¶
const ( DefaultStateFile = ".leapsql/state.db" DefaultEnv = "dev" DefaultOutput = "auto" // Auto-detect: TTY=text, non-TTY=markdown )
CLI-specific default configuration values. Shared defaults (ModelsDir, SeedsDir, MacrosDir) come from internal/config.
Variables ¶
This section is empty.
Functions ¶
func DefaultSchemaForType ¶
DefaultSchemaForType returns the default schema for a database type. This is a convenience wrapper that delegates to the shared config function.
func GetConfigFileUsed ¶
func GetConfigFileUsed() string
GetConfigFileUsed returns the path to the config file being used, if any.
func LoggerKey ¶
func LoggerKey() interface{}
LoggerKey returns the context key used for storing the logger. This allows the commands package to retrieve the logger from context without creating an import cycle with the cli package.
func MergeTargetConfig ¶
func MergeTargetConfig(base, override *core.TargetConfig) *core.TargetConfig
MergeTargetConfig merges two target configs, with override taking precedence.
Types ¶
type Config ¶
type Config struct {
ProjectRoot string `koanf:"-"` // Computed project root, not from config file
ModelsDir string `koanf:"models_dir"`
SeedsDir string `koanf:"seeds_dir"`
MacrosDir string `koanf:"macros_dir"`
DatabasePath string `koanf:"database"` // Deprecated: use Target.Database
StatePath string `koanf:"state_path"`
Environment string `koanf:"environment"`
Verbose bool `koanf:"verbose"`
OutputFormat string `koanf:"output"`
Target *core.TargetConfig `koanf:"target"`
Lint *core.LintConfig `koanf:"lint"`
UI *UIConfig `koanf:"ui"`
Environments map[string]EnvConfig `koanf:"environments"`
}
Config holds all CLI configuration options.
func GetCurrentConfig ¶
func GetCurrentConfig() *Config
GetCurrentConfig returns the currently loaded configuration. This is available after LoadConfig or LoadConfigWithTarget is called.
func LoadConfig ¶
LoadConfig loads configuration from file, environment variables, and flags. Precedence (highest to lowest): flags > env vars > config file > defaults
func LoadConfigWithTarget ¶
func LoadConfigWithTarget(cfgFile string, targetOverride string, flags *pflag.FlagSet) (*Config, error)
LoadConfigWithTarget loads configuration with an optional target override. The targetOverride parameter specifies which environment's target to use. The flags parameter allows CLI flags to override config file and env var values.
func (*Config) GetUIConfig ¶
GetUIConfig returns the UI config with defaults applied for any unset values.
func (*Config) ValidateDirectories ¶
ValidateDirectories checks if required directories exist.
type EnvConfig ¶
type EnvConfig struct {
DatabasePath string `koanf:"database"` // Deprecated: use Target.Database
ModelsDir string `koanf:"models_dir"`
SeedsDir string `koanf:"seeds_dir"`
MacrosDir string `koanf:"macros_dir"`
Target *core.TargetConfig `koanf:"target"`
}
EnvConfig holds environment-specific configuration overrides.
type UIConfig ¶
type UIConfig struct {
Port int `koanf:"port"`
AutoOpen bool `koanf:"auto_open"`
Watch bool `koanf:"watch"`
Theme string `koanf:"theme"`
DataPreviewLimit int `koanf:"data_preview_limit"`
}
UIConfig holds configuration for the UI server.
func DefaultUIConfig ¶
func DefaultUIConfig() *UIConfig
DefaultUIConfig returns a UIConfig with default values.