option

package
v1.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientOption

type ClientOption interface {
	Apply(*Options)
}

func WithCustomUsage

func WithCustomUsage() ClientOption

WithCustomUsage generates usage for -help flag from input struct. By default EnvConf uses this function. Use `option.WithoutCustomUsage` to disable it

func WithFlagParsed

func WithFlagParsed(flagParsed func() error) ClientOption

WithFlagParsed define this callback when you need handle flags This callback will raise after method flag.Parse() return not nil error interrupt pasring

func WithPriorityOrder

func WithPriorityOrder(s ...ConfigSource) ClientOption

WithPriorityOrder overrides default priority order, with an order from function argument. Default priority order is: Flag, Environment variable, External source, Default value.

func WithoutCustomUsage

func WithoutCustomUsage() ClientOption

type ConfigSource

type ConfigSource int
const (
	FlagVariable ConfigSource = iota
	EnvVariable
	ExternalSource
	DefaultValue
)

func (ConfigSource) String

func (s ConfigSource) String() string

type FieldDefineErrorArg

type FieldDefineErrorArg struct {
	Name     string
	FullName string
	Type     reflect.Type
	Err      error
}

type FieldDefinedArg

type FieldDefinedArg struct {
	Name        string
	FullName    string
	Type        reflect.Type
	Required    bool
	Description string

	FlagName     string
	EnvName      string
	DefaultValue interface{}

	Source ConfigSource
	Value  interface{}
}

type FieldInitializedArg

type FieldInitializedArg struct {
	Name        string
	FullName    string
	Type        reflect.Type
	Required    bool
	Description string

	FlagName     string
	EnvName      string
	DefaultValue interface{}
}

type Logger

type Logger struct {
	Printer
	// Enable secrets hide
	HideSecrets bool
	// Regex for match secrets by field name in lower case
	SecretMatchRegex string
}

func WithLog

func WithLog(p Printer) *Logger

SetLogger define printer. This logger will print defined values and errors to Printer.Print method. By Default all secrets will be hidden

func (*Logger) Apply

func (l *Logger) Apply(opts *Options)

type Options

type Options struct {
	// contains filtered or unexported fields
}

func (*Options) FlagParsed

func (o *Options) FlagParsed() func() error

func (*Options) OnFieldDefineErr

func (o *Options) OnFieldDefineErr(arg FieldDefineErrorArg)

func (*Options) OnFieldDefined

func (o *Options) OnFieldDefined(arg FieldDefinedArg)

func (*Options) OnFieldInitialized

func (o *Options) OnFieldInitialized(arg FieldInitializedArg)

func (*Options) PriorityOrder

func (o *Options) PriorityOrder() []ConfigSource

func (*Options) Usage

func (o *Options) Usage() func()

type Printer

type Printer interface {
	Print(...interface{})
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL