Documentation ¶
Index ¶
- Constants
- func IsCmdErr(err error) bool
- func SetClientHook(rootCmd *cobra.Command, applyFunc func(cmd *cobra.Command))
- func SetCompletionCmd(exec string) *cobra.Command
- func SetHelp(cmd *cobra.Command)
- func SetHelpTopicCmd(title string, topic map[string]string) *cobra.Command
- func SetRefCmd(root *cobra.Command) *cobra.Command
- type Config
- type ConfigLoaderOpts
Constants ¶
const ( ODPF_CONFIG_DIR = "ODPF_CONFIG_DIR" XDG_CONFIG_HOME = "XDG_CONFIG_HOME" APP_DATA = "AppData" LOCAL_APP_DATA = "LocalAppData" )
const ( USAGE = "Usage" CORECMD = "Core commands" HELPCMD = "Help topics" OTHERCMD = "Other commands" FLAGS = "Flags" IFLAGS = "Inherited flags" ARGUMENTS = "Arguments" EXAMPLES = "Examples" ENVS = "Environment variables" LEARN = "Learn more" FEEDBACK = "Feedback" )
Variables ¶
This section is empty.
Functions ¶
func IsCmdErr ¶
IsCmdErr returns true if erorr is cobra command error. This is useful for distinguishing between a human error and a program error and displaying the correct message.
func SetClientHook ¶ added in v0.2.0
SetClientHook applies custom cobra config specific for client or cmd that have annotation `client:true`
func SetCompletionCmd ¶
SetCompletionCmd is used to generate the completion script in bash, zsh, fish, and powershell. It should be added on the root command and can be used as `completion bash` or `completion zsh`.
func SetHelp ¶
SetHelp sets a custom help and usage function. It allows to group commands in different sections based on cobra commands annotations.
func SetHelpTopicCmd ¶
SetHelpTopicCmd sets the help topic command. This should be added on the root command. e.g.
topic := map[string]string{"short": "Env","long": "Environment","example": "example",}
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func SetConfig ¶
SetConfig allows to set a client config file. It is used to load and save a config file for command line clients.
func (*Config) Load ¶
func (c *Config) Load(cfg interface{}, opts ...ConfigLoaderOpts) error
type ConfigLoaderOpts ¶ added in v0.2.0
type ConfigLoaderOpts func(c *Config)
func WithFlags ¶ added in v0.2.0
func WithFlags(pfs *pflag.FlagSet) ConfigLoaderOpts