Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalDotEnv ¶
func RegisterFlags ¶
func RegisterFlags[T any](config *T, persistent bool, app *cobra.Command, options ...ParseOption) func() error
Parse takes every object and is able to fill and validate that object depending on config file, env file and flag values. https://github.com/knadh/koanf Your passed struct must define . delimited koanf struct tags in order to match env/.env and flag values to your struct. Additionally your struct may define a Validate() error method which is called at the end of parsing the config Registers flags and returns a parser function that can be used as PreRunE.
Types ¶
type Config ¶
type Config struct { DiscordToken string `koanf:"discord.token" short:"t" description:"Discord App token." validate:"required"` DiscordSuperAdmins string `` /* 128-byte string literal not displayed */ SuperAdmins []discord.UserID GuildIDString string `koanf:"discord.guild.id" short:"g" description:"Discord Bot Owner Guild ID" validate:"required"` GuildID discord.GuildID ChannelIDString string `koanf:"discord.channel.id" short:"i" description:"Discord Bot Owner ChannelID for logs"` ChannelID discord.ChannelID PollInterval time.Duration `koanf:"poll.interval" short:"p" description:"Poll interval for DDNet's http master server"` LegacyMessageFormat bool `koanf:"legacy.format" short:"l" description:"Use legacy message format. If disabled, rich text embeddings will be used."` PostgresHostname string `koanf:"postgres.hostname" short:"H" description:"Postgres host" validate:"required"` PostgresPort uint16 `koanf:"postgres.port" short:"P" description:"Postgres port" validate:"required"` PostgresUser string `koanf:"postgres.user" short:"U" description:"Postgres user" validate:"required"` PostgresPassword string `koanf:"postgres.password" short:"W" description:"Postgres password" validate:"required"` PostgresDatabase string `koanf:"postgres.database" short:"D" description:"Postgres database" validate:"required"` PostgresSSLMode db.SSLMode `koanf:"postgres.sslmode" short:"S" description:"Postgres ssl mode" validate:"required"` }
type ParseOption ¶
type ParseOption func(*parseOption)
func WithDelimiter ¶
func WithDelimiter(delimiter string) ParseOption
func WithDescriptionStructTagName ¶
func WithDescriptionStructTagName(tag string) ParseOption
func WithEnvPrefix ¶
func WithEnvPrefix(prefix string) ParseOption
func WithStructTagName ¶
func WithStructTagName(tag string) ParseOption
func WithoutConfigFile ¶
func WithoutConfigFile() ParseOption
WithoutConfigFile removes the -c or --config flag from the command
type Validatable ¶
type Validatable interface {
Validate() error
}
Click to show internal directories.
Click to hide internal directories.