basicflag

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: MIT Imports: 3 Imported by: 8

Documentation

Overview

Package basicflag implements a koanf.Provider that reads commandline parameters as conf maps using the Go's flag package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pflag

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

Pflag implements a pflag command line provider.

func Provider

func Provider(f *flag.FlagSet, delim string) *Pflag

Provider returns a commandline flags provider that returns a nested map[string]interface{} of environment variable where the nesting hierarchy of keys are defined by delim. For instance, the delim "." will convert the key `parent.child.key: 1` to `{parent: {child: {key: 1}}}`.

func ProviderWithValue added in v0.16.0

func ProviderWithValue(f *flag.FlagSet, delim string, cb func(key string, value string) (string, interface{})) *Pflag

ProviderWithValue works exactly the same as Provider except the callback takes a (key, value) with the variable name and value and allows you to modify both. This is useful for cases where you may want to return other types like a string slice instead of just a string.

func (*Pflag) Read

func (p *Pflag) Read() (map[string]interface{}, error)

Read reads the flag variables and returns a nested conf map.

func (*Pflag) ReadBytes

func (p *Pflag) ReadBytes() ([]byte, error)

ReadBytes is not supported by the basicflag koanf.

func (*Pflag) Watch added in v0.5.0

func (p *Pflag) Watch(cb func(event interface{}, err error)) error

Watch is not supported.

Jump to

Keyboard shortcuts

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