cmdx

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 20 Imported by: 13

Documentation

Index

Constants

View Source
const (
	GOTOCOMPANY_CONFIG_DIR = "GOTOCOMPANY_CONFIG_DIR"
	XDG_CONFIG_HOME        = "XDG_CONFIG_HOME"
	APP_DATA               = "AppData"
)
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 GenerateMarkdownTree

func GenerateMarkdownTree(rootOutputPath string, cmd *cobra.Command) error

GenerateMarkdownTree generate cobra cmd commands tree as markdown file rootOutputPath determines the folder where the markdown files are written

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

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 ...ConfigLoaderOpt) error

func (*Config) Read

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

func (*Config) Write

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

type ConfigLoaderOpt

type ConfigLoaderOpt func(c *Config)

func WithFlags

func WithFlags(pfs *pflag.FlagSet) ConfigLoaderOpt

func WithLoaderOptions added in v0.3.3

func WithLoaderOptions(opts ...config.LoaderOption) ConfigLoaderOpt

Jump to

Keyboard shortcuts

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