go-ucfg: github.com/elastic/go-ucfg/flag Index | Files

package flag

import "github.com/elastic/go-ucfg/flag"

Index

Package Files

file.go flag.go util.go value.go

func Config Uses

func Config(
    set *goflag.FlagSet,
    name string,
    usage string,
    opts ...ucfg.Option,
) *ucfg.Config

func ConfigVar Uses

func ConfigVar(
    set *goflag.FlagSet,
    def *ucfg.Config,
    name string,
    usage string,
    opts ...ucfg.Option,
) *ucfg.Config

type FileLoader Uses

type FileLoader func(name string, opts ...ucfg.Option) (*ucfg.Config, error)

FileLoader is used by NewFlagFiles to define customer file loading functions for different file extensions.

type FlagValue Uses

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

func ConfigFiles Uses

func ConfigFiles(
    set *goflag.FlagSet,
    name string,
    usage string,
    extensions map[string]FileLoader,
    opts ...ucfg.Option,
) *FlagValue

func ConfigFilesExts Uses

func ConfigFilesExts(
    set *goflag.FlagSet,
    name string,
    usage string,
    opts ...ucfg.Option,
) *FlagValue

func ConfigFilesExtsVar Uses

func ConfigFilesExtsVar(
    set *goflag.FlagSet,
    def *ucfg.Config,
    name string,
    usage string,
    opts ...ucfg.Option,
) *FlagValue

func ConfigFilesVar Uses

func ConfigFilesVar(
    set *goflag.FlagSet,
    def *ucfg.Config,
    name string,
    usage string,
    extensions map[string]FileLoader,
    opts ...ucfg.Option,
) *FlagValue

func ConfigJSONFiles Uses

func ConfigJSONFiles(
    set *goflag.FlagSet,
    name string,
    usage string,
    opts ...ucfg.Option,
) *FlagValue

func ConfigJSONFilesVar Uses

func ConfigJSONFilesVar(
    set *goflag.FlagSet,
    def *ucfg.Config,
    name string,
    usage string,
    opts ...ucfg.Option,
) *FlagValue

func ConfigYAMLFiles Uses

func ConfigYAMLFiles(
    set *goflag.FlagSet,
    name string,
    usage string,
    opts ...ucfg.Option,
) *FlagValue

func ConfigYAMLFilesVar Uses

func ConfigYAMLFilesVar(
    set *goflag.FlagSet,
    def *ucfg.Config,
    name string,
    usage string,
    opts ...ucfg.Option,
) *FlagValue

func NewFlagFiles Uses

func NewFlagFiles(
    cfg *ucfg.Config,
    extensions map[string]FileLoader,
    opts ...ucfg.Option,
) *FlagValue

NewFlagFiles create a new flag, that will load external configurations file when being used. Configurations loaded from multiple files will be merged into one common Config object. If cfg is not nil, then the loaded configurations will be merged into cfg. The extensions parameter define custom file loaders for different file extensions. If extensions contains an entry with key "", then this loader will be used as default fallback.

func NewFlagKeyValue Uses

func NewFlagKeyValue(cfg *ucfg.Config, autoBool bool, opts ...ucfg.Option) *FlagValue

NewFlagKeyValue implements the flag.Value interface for capturing ucfg.Config settings from command line arguments. Configuration options follow the argument name and must be in the form of "key=value". Using 'D' as command line flag for example, options on command line must be given as:

-D key1=value -D key=value

Note: the space between command line option and key is required by the flag package to parse command line flags correctly.

Note: it's valid to use a key multiple times. If keys are used multiple times, values get overwritten. The last known value for some key will be stored in the generated configuration.

The type of value must be any of bool, uint, int, float, or string. Any kind of array or object syntax is not supported.

If autoBool is enabled (default if Config or ConfigVar is used), keys without value are converted to bool variable with value being true.

func (*FlagValue) Config Uses

func (v *FlagValue) Config() *ucfg.Config

func (*FlagValue) Error Uses

func (v *FlagValue) Error() error

func (*FlagValue) Get Uses

func (v *FlagValue) Get() interface{}

func (*FlagValue) Set Uses

func (v *FlagValue) Set(arg string) error

func (*FlagValue) String Uses

func (v *FlagValue) String() string

Package flag imports 10 packages (graph) and is imported by 30 packages. Updated 2019-02-12. Refresh now. Tools for package owners.