Documentation
¶
Overview ¶
Package cli provides the CLI config component of go-micro.
Package cli provides cli.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Plugins contains source/cli subplugins, for example urfave, pflag, cobra. Plugins = container.NewMap[string, ParseFunc]() // Flags is the global flag container where you have to register flags with. Flags = container.NewList[*Flag]() )
View Source
var ( // DefaultCLIPlugin holds the default CLI plugin. DefaultCLIPlugin = "urfave" //nolint:gochecknoglobals )
View Source
var ( // ErrFlagExists is returned when the given element exists in the flag container. ErrFlagExists = errors.New("element exists already") )
Functions ¶
Types ¶
type Config ¶
type Config struct {
Name string `json:"name" yaml:"name"`
Version string `json:"version" yaml:"version"`
}
Config is the base config for this component.
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{}
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.
Click to show internal directories.
Click to hide internal directories.