Labels: type:feature, area:cli, priority:high,
status:blocked, milestone:M1, phase:1
Summary
Integrate viper for configuration sourced from CLI flags, environment
variables, and a YAML config file, in that precedence order.
Acceptance criteria
Implementation notes
Use github.com/spf13/viper v1.18+. Bind viper to the cobra root command
in internal/cli/root.go's PersistentPreRunE.
Dependencies
Depends on: #4
Verification
FORKGUARD_DB_PATH=/tmp/test.db ./forkguard --help
go test ./internal/config/...
Labels:
type:feature,area:cli,priority:high,status:blocked,milestone:M1,phase:1Summary
Integrate viper for configuration sourced from CLI flags, environment
variables, and a YAML config file, in that precedence order.
Acceptance criteria
internal/config/config.godefines aConfigstruct with:DBPath string(default~/.forkguard/state.db,env
FORKGUARD_DB_PATH)CacheDir string(default~/.forkguard/cache,env
FORKGUARD_CACHE_DIR)GitHubToken string(default empty, envGITHUB_TOKEN)LogFormat string(defaultjson, envFORKGUARD_LOG_FORMAT)LogLevel string(defaultinfo, envFORKGUARD_LOG_LEVEL)Load(cmd *cobra.Command) (*Config, error)populates the config fromflags, env vars, and a YAML file (in that precedence)
~/.forkguard/config.yamlImplementation notes
Use
github.com/spf13/viperv1.18+. Bind viper to the cobra root commandin
internal/cli/root.go'sPersistentPreRunE.Dependencies
Depends on: #4
Verification
FORKGUARD_DB_PATH=/tmp/test.db ./forkguard --help go test ./internal/config/...