cmdx

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ODPF_CONFIG_DIR = "ODPF_CONFIG_DIR"
	XDG_CONFIG_HOME = "XDG_CONFIG_HOME"
	APP_DATA        = "AppData"
	LOCAL_APP_DATA  = "LocalAppData"
)
View Source
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

func IsCmdErr(err error) bool

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

func SetClientHook(rootCmd *cobra.Command, applyFunc func(cmd *cobra.Command))

SetClientHook applies custom cobra config specific for client or cmd that have annotation `client:true`

func SetCompletionCmd

func SetCompletionCmd(exec string) *cobra.Command

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

func SetHelp(cmd *cobra.Command)

SetHelp sets a custom help and usage function. It allows to group commands in different sections based on cobra commands annotations.

func SetHelpTopicCmd

func SetHelpTopicCmd(title string, topic map[string]string) *cobra.Command

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",}

func SetRefCmd

func SetRefCmd(root *cobra.Command) *cobra.Command

SetRefCmd is used to generate the reference documentation in markdown format for the command tree. This should be added on the root command and can be used as `help reference` or `reference help`.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func SetConfig

func SetConfig(app string) *Config

SetConfig allows to set a client config file. It is used to load and save a config file for command line clients.

func (*Config) Defaults

func (c *Config) Defaults(cfg interface{})

func (*Config) File

func (c *Config) File() string

func (*Config) Init

func (c *Config) Init(cfg interface{}) error

func (*Config) Load

func (c *Config) Load(cfg interface{}, opts ...ConfigLoaderOpts) error

func (*Config) Read

func (c *Config) Read() (string, error)

func (*Config) Write added in v0.2.3

func (c *Config) Write(cfg interface{}) 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL