# README
cli
A wrapper on top of cobra.Command
to build
CLIs with a functional style.
Command builder
- no globals, only functions
- inject
viper.Viper
configuration registry - allow dependency injection (e.g. logger, etc)
Utilities
- injectable: logger, config that can be passed via context
- wait: command sync utilities, e.g. to run as deployed containers & sync on events
- version: retrieve version from go module information, or values baked at build-time
TODOs
# Functions
BindFlagToConfig declares the flag as bound to a configuration key in the viper registry.
Config calls ConfigForEnv, with the current environment resolved from the variable "CONFIG_ENV".
ConfigForEnv loads and merge a set of config files for a given environment and applies some default values.
ConfigForEnvWithOptions loads and merge a set of config files for a given environment and applies some default values.
Die exits the current process with some final croak.
FlagIsPersistent declares the flag as persistent for the command.
FlagIsRequired declares the flag as required for the command.
Must panic on error.
MustBindFromFlagSet binds a key in a *viper.Viper registry to command-line flag found in a flag set (*pflag.FlagSet).
MustBindPlag binds a key in a *viper.Viper registry to a command-line flag (*pflag.Flag).
MustOrDie dies on error.
NewCommand builds a new Command wrapping a *cobra.Command.
SetConfigOption defines package-level defaults for config options, when using ConfigForEnv or Config.
SetDie alters the package level log.Fatalf implementation, to be used by Die(sring, ...any).
WithAutoVersion wires a "--version" flag using version.Resolve().
WithBindFlagsToConfig binds all (non persistent) flags in the provided map to a config key.
WithBindPersistentFlagsToConfig binds all persistent flags in the provided map to a config key.
WithCobraOptions adds any setter that takes the cobra command as input.
WithConfig adds a viper.Viper configuration to the command tree.
WithFlag declares a flag of any type supported by gflag, with some options.
WithFlagFunc declares a command flag using a RegisterFunc function and some flag options.
WithFlagP declares a flag of any type supported by gflag, with a shorthand name and some options.
WithFlagVar declares a flag of any type supported by gflag, with some options.
WithFlagVarP declares a flag of any type supported by gflag, with a shorthand name and some options.
WithInjectables adds dependencies to be injected in the context of the command.
WithSliceFlag declares a flag of any slice type supported by gflag, with some options.
WithSliceFlagP declares a flag of any slice type supported by gflag, with a shorthand name and some options.
WithSliceFlagVar declares a flag of any slice type supported by gflag, with some options.
WithSliceFlagVarP declares a flag of any slice type supported by gflag, with a shorthand name and some options.
WithSubCommands adds child commands.
WithVersion wires a "--version" flag from a function evaluated at command construction time.
# Variables
ConfigDebugEnv defines the environment variable used to instruct the config loader to dump all config keys for debugging.
ConfigEnv defines the environment variable used by the Config() function to find the current environment (i.e.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author