...

Package altsrc

import "github.com/urfave/cli/v2/altsrc"
Overview
Index

Overview ▾

Index ▾

func ApplyInputSourceValues(cCtx *cli.Context, inputSourceContext InputSourceContext, flags []cli.Flag) error
func InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceContext, error)) cli.BeforeFunc
func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(cCtx *cli.Context) (InputSourceContext, error)) cli.BeforeFunc
func NewJSONSourceFromFlagFunc(flag string) func(c *cli.Context) (InputSourceContext, error)
func NewTomlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error)
func NewYamlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error)
type BoolFlag
    func NewBoolFlag(fl *cli.BoolFlag) *BoolFlag
    func (f *BoolFlag) Apply(set *flag.FlagSet) error
    func (f *BoolFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type DurationFlag
    func NewDurationFlag(fl *cli.DurationFlag) *DurationFlag
    func (f *DurationFlag) Apply(set *flag.FlagSet) error
    func (f *DurationFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type FlagInputSourceExtension
type Float64Flag
    func NewFloat64Flag(fl *cli.Float64Flag) *Float64Flag
    func (f *Float64Flag) Apply(set *flag.FlagSet) error
    func (f *Float64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type Float64SliceFlag
    func NewFloat64SliceFlag(fl *cli.Float64SliceFlag) *Float64SliceFlag
    func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error
    func (f *Float64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type GenericFlag
    func NewGenericFlag(fl *cli.GenericFlag) *GenericFlag
    func (f *GenericFlag) Apply(set *flag.FlagSet) error
    func (f *GenericFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type InputSourceContext
    func NewJSONSource(data []byte) (InputSourceContext, error)
    func NewJSONSourceFromFile(f string) (InputSourceContext, error)
    func NewJSONSourceFromReader(r io.Reader) (InputSourceContext, error)
    func NewTomlSourceFromFile(file string) (InputSourceContext, error)
    func NewYamlSourceFromFile(file string) (InputSourceContext, error)
type Int64Flag
    func NewInt64Flag(fl *cli.Int64Flag) *Int64Flag
    func (f *Int64Flag) Apply(set *flag.FlagSet) error
    func (f *Int64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type Int64SliceFlag
    func NewInt64SliceFlag(fl *cli.Int64SliceFlag) *Int64SliceFlag
    func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error
    func (f *Int64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type IntFlag
    func NewIntFlag(fl *cli.IntFlag) *IntFlag
    func (f *IntFlag) Apply(set *flag.FlagSet) error
    func (f *IntFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type IntSliceFlag
    func NewIntSliceFlag(fl *cli.IntSliceFlag) *IntSliceFlag
    func (f *IntSliceFlag) Apply(set *flag.FlagSet) error
    func (f *IntSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type MapInputSource
    func NewMapInputSource(file string, valueMap map[interface{}]interface{}) *MapInputSource
    func (fsm *MapInputSource) Bool(name string) (bool, error)
    func (fsm *MapInputSource) Duration(name string) (time.Duration, error)
    func (fsm *MapInputSource) Float64(name string) (float64, error)
    func (fsm *MapInputSource) Float64Slice(name string) ([]float64, error)
    func (fsm *MapInputSource) Generic(name string) (cli.Generic, error)
    func (fsm *MapInputSource) Int(name string) (int, error)
    func (fsm *MapInputSource) Int64(name string) (int64, error)
    func (fsm *MapInputSource) Int64Slice(name string) ([]int64, error)
    func (fsm *MapInputSource) IntSlice(name string) ([]int, error)
    func (fsm *MapInputSource) Source() string
    func (fsm *MapInputSource) String(name string) (string, error)
    func (fsm *MapInputSource) StringSlice(name string) ([]string, error)
    func (fsm *MapInputSource) Uint(name string) (uint, error)
    func (fsm *MapInputSource) Uint64(name string) (uint64, error)
type PathFlag
    func NewPathFlag(fl *cli.PathFlag) *PathFlag
    func (f *PathFlag) Apply(set *flag.FlagSet) error
    func (f *PathFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type StringFlag
    func NewStringFlag(fl *cli.StringFlag) *StringFlag
    func (f *StringFlag) Apply(set *flag.FlagSet) error
    func (f *StringFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type StringSliceFlag
    func NewStringSliceFlag(fl *cli.StringSliceFlag) *StringSliceFlag
    func (f *StringSliceFlag) Apply(set *flag.FlagSet) error
    func (f *StringSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type Uint64Flag
    func NewUint64Flag(fl *cli.Uint64Flag) *Uint64Flag
    func (f *Uint64Flag) Apply(set *flag.FlagSet) error
    func (f *Uint64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
type UintFlag
    func NewUintFlag(fl *cli.UintFlag) *UintFlag
    func (f *UintFlag) Apply(set *flag.FlagSet) error
    func (f *UintFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

Package files

default_input_source.go flag.go flag_generated.go input_source_context.go json_source_context.go map_input_source.go toml_file_loader.go yaml_file_loader.go

func ApplyInputSourceValues

func ApplyInputSourceValues(cCtx *cli.Context, inputSourceContext InputSourceContext, flags []cli.Flag) error

ApplyInputSourceValues iterates over all provided flags and executes ApplyInputSourceValue on flags implementing the FlagInputSourceExtension interface to initialize these flags to an alternate input source.

func InitInputSource

func InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceContext, error)) cli.BeforeFunc

InitInputSource is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new input source based on the func provided. If there is no error it will then apply the new input source to any flags that are supported by the input source

func InitInputSourceWithContext

func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(cCtx *cli.Context) (InputSourceContext, error)) cli.BeforeFunc

InitInputSourceWithContext is used to to setup an InputSourceContext on a cli.Command Before method. It will create a new input source based on the func provided with potentially using existing cli.Context values to initialize itself. If there is no error it will then apply the new input source to any flags that are supported by the input source

func NewJSONSourceFromFlagFunc

func NewJSONSourceFromFlagFunc(flag string) func(c *cli.Context) (InputSourceContext, error)

NewJSONSourceFromFlagFunc returns a func that takes a cli.Context and returns an InputSourceContext suitable for retrieving config variables from a file containing JSON data with the file name defined by the given flag.

func NewTomlSourceFromFlagFunc

func NewTomlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error)

NewTomlSourceFromFlagFunc creates a new TOML InputSourceContext from a provided flag name and source context.

func NewYamlSourceFromFlagFunc

func NewYamlSourceFromFlagFunc(flagFileName string) func(cCtx *cli.Context) (InputSourceContext, error)

NewYamlSourceFromFlagFunc creates a new Yaml InputSourceContext from a provided flag name and source context.

type BoolFlag

BoolFlag is the flag type that wraps cli.BoolFlag to allow for other values to be specified

type BoolFlag struct {
    *cli.BoolFlag
    // contains filtered or unexported fields
}

func NewBoolFlag

func NewBoolFlag(fl *cli.BoolFlag) *BoolFlag

NewBoolFlag creates a new BoolFlag

func (*BoolFlag) Apply

func (f *BoolFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped BoolFlag.Apply

func (*BoolFlag) ApplyInputSourceValue

func (f *BoolFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a Bool value to the flagSet if required

type DurationFlag

DurationFlag is the flag type that wraps cli.DurationFlag to allow for other values to be specified

type DurationFlag struct {
    *cli.DurationFlag
    // contains filtered or unexported fields
}

func NewDurationFlag

func NewDurationFlag(fl *cli.DurationFlag) *DurationFlag

NewDurationFlag creates a new DurationFlag

func (*DurationFlag) Apply

func (f *DurationFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped DurationFlag.Apply

func (*DurationFlag) ApplyInputSourceValue

func (f *DurationFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a Duration value to the flagSet if required

type FlagInputSourceExtension

FlagInputSourceExtension is an extension interface of cli.Flag that allows a value to be set on the existing parsed flags.

type FlagInputSourceExtension interface {
    cli.Flag
    ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error
}

type Float64Flag

Float64Flag is the flag type that wraps cli.Float64Flag to allow for other values to be specified

type Float64Flag struct {
    *cli.Float64Flag
    // contains filtered or unexported fields
}

func NewFloat64Flag

func NewFloat64Flag(fl *cli.Float64Flag) *Float64Flag

NewFloat64Flag creates a new Float64Flag

func (*Float64Flag) Apply

func (f *Float64Flag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped Float64Flag.Apply

func (*Float64Flag) ApplyInputSourceValue

func (f *Float64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a Float64 value to the flagSet if required

type Float64SliceFlag

Float64SliceFlag is the flag type that wraps cli.Float64SliceFlag to allow for other values to be specified

type Float64SliceFlag struct {
    *cli.Float64SliceFlag
    // contains filtered or unexported fields
}

func NewFloat64SliceFlag

func NewFloat64SliceFlag(fl *cli.Float64SliceFlag) *Float64SliceFlag

NewFloat64SliceFlag creates a new Float64SliceFlag

func (*Float64SliceFlag) Apply

func (f *Float64SliceFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped Float64SliceFlag.Apply

func (*Float64SliceFlag) ApplyInputSourceValue

func (f *Float64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a Float64Slice value if required

type GenericFlag

GenericFlag is the flag type that wraps cli.GenericFlag to allow for other values to be specified

type GenericFlag struct {
    *cli.GenericFlag
    // contains filtered or unexported fields
}

func NewGenericFlag

func NewGenericFlag(fl *cli.GenericFlag) *GenericFlag

NewGenericFlag creates a new GenericFlag

func (*GenericFlag) Apply

func (f *GenericFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped GenericFlag.Apply

func (*GenericFlag) ApplyInputSourceValue

func (f *GenericFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a generic value to the flagSet if required

type InputSourceContext

InputSourceContext is an interface used to allow other input sources to be implemented as needed.

Source returns an identifier for the input source. In case of file source it should return path to the file.

type InputSourceContext interface {
    Source() string

    Int(name string) (int, error)
    Int64(name string) (int64, error)
    Uint(name string) (uint, error)
    Uint64(name string) (uint64, error)
    Duration(name string) (time.Duration, error)
    Float64(name string) (float64, error)
    String(name string) (string, error)
    StringSlice(name string) ([]string, error)
    IntSlice(name string) ([]int, error)
    Int64Slice(name string) ([]int64, error)
    Float64Slice(name string) ([]float64, error)
    Generic(name string) (cli.Generic, error)
    Bool(name string) (bool, error)
    // contains filtered or unexported methods
}

func NewJSONSource

func NewJSONSource(data []byte) (InputSourceContext, error)

NewJSONSource returns an InputSourceContext suitable for retrieving config variables from raw JSON data.

func NewJSONSourceFromFile

func NewJSONSourceFromFile(f string) (InputSourceContext, error)

NewJSONSourceFromFile returns an InputSourceContext suitable for retrieving config variables from a file (or url) containing JSON data.

func NewJSONSourceFromReader

func NewJSONSourceFromReader(r io.Reader) (InputSourceContext, error)

NewJSONSourceFromReader returns an InputSourceContext suitable for retrieving config variables from an io.Reader that returns JSON data.

func NewTomlSourceFromFile

func NewTomlSourceFromFile(file string) (InputSourceContext, error)

NewTomlSourceFromFile creates a new TOML InputSourceContext from a filepath.

func NewYamlSourceFromFile

func NewYamlSourceFromFile(file string) (InputSourceContext, error)

NewYamlSourceFromFile creates a new Yaml InputSourceContext from a filepath.

type Int64Flag

Int64Flag is the flag type that wraps cli.Int64Flag to allow for other values to be specified

type Int64Flag struct {
    *cli.Int64Flag
    // contains filtered or unexported fields
}

func NewInt64Flag

func NewInt64Flag(fl *cli.Int64Flag) *Int64Flag

NewInt64Flag creates a new Int64Flag

func (*Int64Flag) Apply

func (f *Int64Flag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped Int64Flag.Apply

func (*Int64Flag) ApplyInputSourceValue

func (f *Int64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

type Int64SliceFlag

Int64SliceFlag is the flag type that wraps cli.Int64SliceFlag to allow for other values to be specified

type Int64SliceFlag struct {
    *cli.Int64SliceFlag
    // contains filtered or unexported fields
}

func NewInt64SliceFlag

func NewInt64SliceFlag(fl *cli.Int64SliceFlag) *Int64SliceFlag

NewInt64SliceFlag creates a new Int64SliceFlag

func (*Int64SliceFlag) Apply

func (f *Int64SliceFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped Int64SliceFlag.Apply

func (*Int64SliceFlag) ApplyInputSourceValue

func (f *Int64SliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a Int64Slice value if required

type IntFlag

IntFlag is the flag type that wraps cli.IntFlag to allow for other values to be specified

type IntFlag struct {
    *cli.IntFlag
    // contains filtered or unexported fields
}

func NewIntFlag

func NewIntFlag(fl *cli.IntFlag) *IntFlag

NewIntFlag creates a new IntFlag

func (*IntFlag) Apply

func (f *IntFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped IntFlag.Apply

func (*IntFlag) ApplyInputSourceValue

func (f *IntFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a int value to the flagSet if required

type IntSliceFlag

IntSliceFlag is the flag type that wraps cli.IntSliceFlag to allow for other values to be specified

type IntSliceFlag struct {
    *cli.IntSliceFlag
    // contains filtered or unexported fields
}

func NewIntSliceFlag

func NewIntSliceFlag(fl *cli.IntSliceFlag) *IntSliceFlag

NewIntSliceFlag creates a new IntSliceFlag

func (*IntSliceFlag) Apply

func (f *IntSliceFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped IntSliceFlag.Apply

func (*IntSliceFlag) ApplyInputSourceValue

func (f *IntSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a IntSlice value if required

type MapInputSource

MapInputSource implements InputSourceContext to return data from the map that is loaded.

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

func NewMapInputSource

func NewMapInputSource(file string, valueMap map[interface{}]interface{}) *MapInputSource

NewMapInputSource creates a new MapInputSource for implementing custom input sources.

func (*MapInputSource) Bool

func (fsm *MapInputSource) Bool(name string) (bool, error)

Bool returns an bool from the map otherwise returns false

func (*MapInputSource) Duration

func (fsm *MapInputSource) Duration(name string) (time.Duration, error)

Duration returns a duration from the map if it exists otherwise returns 0

func (*MapInputSource) Float64

func (fsm *MapInputSource) Float64(name string) (float64, error)

Float64 returns an float64 from the map if it exists otherwise returns 0

func (*MapInputSource) Float64Slice

func (fsm *MapInputSource) Float64Slice(name string) ([]float64, error)

Float64Slice returns an []float64 from the map if it exists otherwise returns nil

func (*MapInputSource) Generic

func (fsm *MapInputSource) Generic(name string) (cli.Generic, error)

Generic returns an cli.Generic from the map if it exists otherwise returns nil

func (*MapInputSource) Int

func (fsm *MapInputSource) Int(name string) (int, error)

Int returns an int from the map if it exists otherwise returns 0

func (*MapInputSource) Int64

func (fsm *MapInputSource) Int64(name string) (int64, error)

Int64 returns an int64 from the map if it exists otherwise returns 0

func (*MapInputSource) Int64Slice

func (fsm *MapInputSource) Int64Slice(name string) ([]int64, error)

Int64Slice returns an []int64 from the map if it exists otherwise returns nil

func (*MapInputSource) IntSlice

func (fsm *MapInputSource) IntSlice(name string) ([]int, error)

IntSlice returns an []int from the map if it exists otherwise returns nil

func (*MapInputSource) Source

func (fsm *MapInputSource) Source() string

Source returns the path of the source file

func (*MapInputSource) String

func (fsm *MapInputSource) String(name string) (string, error)

String returns a string from the map if it exists otherwise returns an empty string

func (*MapInputSource) StringSlice

func (fsm *MapInputSource) StringSlice(name string) ([]string, error)

StringSlice returns an []string from the map if it exists otherwise returns nil

func (*MapInputSource) Uint

func (fsm *MapInputSource) Uint(name string) (uint, error)

Int64 returns an int64 from the map if it exists otherwise returns 0

func (*MapInputSource) Uint64

func (fsm *MapInputSource) Uint64(name string) (uint64, error)

UInt64 returns an uint64 from the map if it exists otherwise returns 0

type PathFlag

PathFlag is the flag type that wraps cli.PathFlag to allow for other values to be specified

type PathFlag struct {
    *cli.PathFlag
    // contains filtered or unexported fields
}

func NewPathFlag

func NewPathFlag(fl *cli.PathFlag) *PathFlag

NewPathFlag creates a new PathFlag

func (*PathFlag) Apply

func (f *PathFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped PathFlag.Apply

func (*PathFlag) ApplyInputSourceValue

func (f *PathFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a Path value to the flagSet if required

type StringFlag

StringFlag is the flag type that wraps cli.StringFlag to allow for other values to be specified

type StringFlag struct {
    *cli.StringFlag
    // contains filtered or unexported fields
}

func NewStringFlag

func NewStringFlag(fl *cli.StringFlag) *StringFlag

NewStringFlag creates a new StringFlag

func (*StringFlag) Apply

func (f *StringFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped StringFlag.Apply

func (*StringFlag) ApplyInputSourceValue

func (f *StringFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a String value to the flagSet if required

type StringSliceFlag

StringSliceFlag is the flag type that wraps cli.StringSliceFlag to allow for other values to be specified

type StringSliceFlag struct {
    *cli.StringSliceFlag
    // contains filtered or unexported fields
}

func NewStringSliceFlag

func NewStringSliceFlag(fl *cli.StringSliceFlag) *StringSliceFlag

NewStringSliceFlag creates a new StringSliceFlag

func (*StringSliceFlag) Apply

func (f *StringSliceFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped StringSliceFlag.Apply

func (*StringSliceFlag) ApplyInputSourceValue

func (f *StringSliceFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

ApplyInputSourceValue applies a StringSlice value to the flagSet if required

type Uint64Flag

Uint64Flag is the flag type that wraps cli.Uint64Flag to allow for other values to be specified

type Uint64Flag struct {
    *cli.Uint64Flag
    // contains filtered or unexported fields
}

func NewUint64Flag

func NewUint64Flag(fl *cli.Uint64Flag) *Uint64Flag

NewUint64Flag creates a new Uint64Flag

func (*Uint64Flag) Apply

func (f *Uint64Flag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped Uint64Flag.Apply

func (*Uint64Flag) ApplyInputSourceValue

func (f *Uint64Flag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error

type UintFlag

UintFlag is the flag type that wraps cli.UintFlag to allow for other values to be specified

type UintFlag struct {
    *cli.UintFlag
    // contains filtered or unexported fields
}

func NewUintFlag

func NewUintFlag(fl *cli.UintFlag) *UintFlag

NewUintFlag creates a new UintFlag

func (*UintFlag) Apply

func (f *UintFlag) Apply(set *flag.FlagSet) error

Apply saves the flagSet for later usage calls, then calls the wrapped UintFlag.Apply

func (*UintFlag) ApplyInputSourceValue

func (f *UintFlag) ApplyInputSourceValue(cCtx *cli.Context, isc InputSourceContext) error