package cmd import ( redner "orus.io/orus-io/go-redner/client" ) type RednerOptions struct { NoSSL bool `long:"no-ssl" ini-name:"no-ssl" description:"disable ssl"` Host string `long:"host" ini-name:"host" description:"Redner host"` APIKey string `long:"api-key" ini-name:"api-key" description:"Redner api-key"` Account string `long:"account" ini-name:"account" description:"Redner account name"` client *redner.Redner } func (options *RednerOptions) Client() *redner.Redner { if options.client == nil && options.Host != "" { schemes := []string{"https"} if options.NoSSL { schemes = []string{"http"} } options.client = redner.NewHTTPClientWithConfig( nil, redner.DefaultTransportConfig().WithHost(options.Host).WithSchemes(schemes), ) options.client.SetAPIKey(options.APIKey) } return options.client } func WithRedner[E any]() Option[E] { return func(program *Program[E]) { g, err := program.Parser.AddGroup("Redner", "Redner options", &program.RednerOptions) if err != nil { panic(err) } g.Namespace = "redner" g.EnvNamespace = "REDNER" } } func (program *Program[E]) Redner() *redner.Redner { return program.RednerOptions.Client() }