Documentation
¶
Overview ¶
Package cmd provides a common utilities and helper function to standarise the way omni apps use cobra and viper to produce consistent cli experience for both users and devs.
Index ¶
- func BindHomeFlag(flags *pflag.FlagSet, homeDir *string)
- func LogFlags(ctx context.Context, flags *pflag.FlagSet) error
- func Main(cmd *cobra.Command)
- func NewRootCmd(appName string, appDescription string, subCmds ...*cobra.Command) *cobra.Command
- func Redact(flag, val string) string
- func SilenceErrUsage(cmd *cobra.Command)
- func WrapRunE(cmd *cobra.Command, printFatal func(ctx context.Context, err error))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindHomeFlag ¶
BindHomeFlag binds the home flag to the given flag set. This is generally only required for apps that require multiple config files or persist data to disk. Using this flag will result in the viper config directory to be updated from default "." to "<home>/config".
func Main ¶
Main is the main entry point for the omni application binaries. Usage:
func main() {
libcmd.Main(appcmd.New())
}
func NewRootCmd ¶
NewRootCmd returns a new root cobra command that handles our command line tool. It sets up the general viper config and binds the cobra flags to the viper flags.
func Redact ¶ added in v0.10.0
Redact returns a redacted version of the given flag value. It currently supports redacting passwords in valid URLs as well as flags that contains words like "token", "password", "secret", "db" or "key".
func SilenceErrUsage ¶
SilenceErrUsage silences the usage and error printing.
Types ¶
This section is empty.