package commands import ( "strings" "github.com/spf13/pflag" "github.com/spf13/viper" ) func LoadConfig[T any](flags *pflag.FlagSet) (*T, error) { var cfg T vipr := viper.New() vipr.SetEnvPrefix("nitter") vipr.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) vipr.AutomaticEnv() if err := vipr.BindPFlags(flags); err != nil { return nil, err } if err := vipr.Unmarshal(&cfg); err != nil { return nil, err } return &cfg, nil }