- Replace global ConfigPath and Overrides with viper-based configuration - Add viper.New() to create configurable viper instances - Store viper and unmarshaled Config struct in context for testability - Add RetrieveFromContext and AddToContext helper functions - Update files.Append to accept context and retrieve config from it - Update formatters.Preferred and formatters.New to accept context - Add PersistentPreRunE in CLI to create and configure viper instance - Support -c flag for custom config file path - Support -v flag for config value overrides - Update all test files to create viper and add to context - Remove unused config types and load functions - Add viper as dependency with automatic env var support (MYLOG_*)
23 lines
379 B
Go
23 lines
379 B
Go
package config
|
|
|
|
type Config struct {
|
|
Input Input
|
|
Outputs Outputs `mapstructure:"output"`
|
|
Formatters Formatters
|
|
}
|
|
|
|
type Input struct {
|
|
Path string
|
|
Recurse bool
|
|
Ext string
|
|
DotFolder bool `mapstructure:"dotFolder"`
|
|
}
|
|
|
|
type Outputs map[string]Output
|
|
|
|
type Output struct {
|
|
Enabled bool
|
|
Config map[string]any
|
|
}
|
|
|
|
type Formatters map[string]map[string]any
|