Documentation
¶
Overview ¶
Package cli provides the CLI config component of go-micro.
Package cli provides cli.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFlagExists is returned when the given element exists in the flag container. ErrFlagExists = errors.New("element exists already") )
var ( // Flags is the global flag container where you have to register flags with. Flags = container.NewList[*Flag]() )
Functions ¶
func ParseFlags ¶ added in v0.2.0
ParseFlags takes the list of flags and parses them into a map[string]any contained inside the result.
func ProvideConfigData ¶ added in v0.2.0
func ProvideConfigData(serviceName types.ServiceName, cliParser ParseFunc) (types.ConfigData, error)
ProvideConfigData provides configData from cli, this requires for example urfave.Provide to be registered first.
Types ¶
type Flag ¶
type Flag struct {
Name string
EnvVars []string
Usage string
// The path in map(\[string\])+any
ConfigPath []string
Default any
Value any
}
Flag is a Cli Flag and maybe environment variable.
type FlagOption ¶
type FlagOption func(*Flag)
FlagOption is an option for NewFlag.
func ConfigPathSlice ¶
func ConfigPathSlice(n []string) FlagOption
ConfigPathSlice is the same as ConfigPath but it accepts a slice.
func EnvVars ¶
func EnvVars(n ...string) FlagOption
EnvVars set's environment variables for the flag.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source cli reads flags and environment variables into a config struct.
func (*Source) PrependSections ¶
PrependSections indicates whether this needs sections to be prepended, which is true in this case.
func (*Source) Read ¶
Read creates the subplugin for the given url, creates its config after and then executes it.