Documentation ¶
Index ¶
- Constants
- Variables
- func AddOnConfigLoadedListener(c ConfigReloaded)
- func DumpAsString() (str string)
- func EnsureDir(dir string) (err error)
- func Exec(rootCmd *RootCommand) (err error)
- func FileExists(name string) bool
- func Get(key string) interface{}
- func GetBool(key string) bool
- func GetCurrentDir() string
- func GetExcutableDir() string
- func GetInt(key string) int64
- func GetString(key string) string
- func GetStringSlice(key string) []string
- func LoadConfigFile(file string) (err error)
- func RemoveOnConfigLoadedListener(c ConfigReloaded)
- func SetOnConfigLoadedListener(c ConfigReloaded, enabled bool)
- type BaseOpt
- func (s *BaseOpt) GetDescZsh() (desc string)
- func (s *BaseOpt) GetTitleFlagNames() string
- func (s *BaseOpt) GetTitleFlagNamesBy(delimChar string) string
- func (s *BaseOpt) GetTitleFlagNamesByMax(delimChar string, maxCount int) string
- func (s *BaseOpt) GetTitleName() string
- func (s *BaseOpt) GetTitleNames() string
- func (s *BaseOpt) GetTitleNamesArray() []string
- func (s *BaseOpt) GetTitleNamesBy(delimChar string) string
- func (s *BaseOpt) GetTitleZshFlagName() (str string)
- func (s *BaseOpt) GetTitleZshFlagNames(delimChar string) (str string)
- func (s *BaseOpt) GetTitleZshFlagNamesArray() (ary []string)
- type Command
- func (c *Command) GetExpandableNames() string
- func (c *Command) GetExpandableNamesArray() []string
- func (c *Command) GetName() string
- func (c *Command) GetParentName() string
- func (c *Command) GetQuotedGroupName() string
- func (c *Command) GetRoot() *RootCommand
- func (c *Command) GetSubCommandNamesBy(delimChar string) string
- func (c *Command) HasParent() bool
- func (c *Command) PrintHelp(justFlags bool)
- func (c *Command) PrintVersion()
- type ConfigReloaded
- type Flag
- type Options
- func (s *Options) DumpAsString() (str string)
- func (s *Options) Get(key string) interface{}
- func (s *Options) GetBool(key string) (ret bool)
- func (s *Options) GetInt(key string) (ir int64)
- func (s *Options) GetString(key string) (ret string)
- func (s *Options) GetStringSlice(key string) (ir []string)
- func (s *Options) LoadConfigFile(file string) (err error)
- func (s *Options) Reset()
- func (s *Options) Set(key string, val interface{})
- func (s *Options) SetNx(key string, val interface{})
- type RootCommand
Constants ¶
View Source
const ( APP_NAME_DEFAULT = "cmdr" UNSORTED_GROUP = "zzzz.unsorted" SYSMGMT = "zzz9.Misc" )
View Source
const ( APP_NAME = "cmdr" // Version = "0.2.1-pre" // VersionInt = 0x000201 // using as )
Variables ¶
View Source
var ( EnableVersionCommands bool = true EnableHelpCommands bool = true EnableVerboseCommands bool = true EnableGenerateCommands bool = true // rootOptions *OptOne RxxtOptions *Options = NewOptions() // RxxtPrefix create a top-level namespace, which contains all normalized `Flag`s. RxxtPrefix = []string{"app"} EnvPrefix = []string{"CMDR"} // ShouldBeStopException = errors.New("should be stop right now") )
Functions ¶
func AddOnConfigLoadedListener ¶
func AddOnConfigLoadedListener(c ConfigReloaded)
func DumpAsString ¶
func DumpAsString() (str string)
func Exec ¶
func Exec(rootCmd *RootCommand) (err error)
func FileExists ¶
func GetCurrentDir ¶
func GetCurrentDir() string
func GetExcutableDir ¶
func GetExcutableDir() string
func GetStringSlice ¶
func LoadConfigFile ¶
func RemoveOnConfigLoadedListener ¶
func RemoveOnConfigLoadedListener(c ConfigReloaded)
func SetOnConfigLoadedListener ¶
func SetOnConfigLoadedListener(c ConfigReloaded, enabled bool)
Types ¶
type BaseOpt ¶
type BaseOpt struct { Name string // single char. example for flag: "a" -> "-a" // Short rune. Short string // word string. example for flag: "addr" -> "--addr" Full string // more synonyms Aliases []string // group name Group string Flags []*Flag Description string LongDescription string Examples string Hidden bool DefaultValuePlaceholder string // cmd 是 flag 被识别时已经得到的子命令 // return: ShouldBeStopException will break the following flow and exit right now Action func(cmd *Command, args []string) (err error) // contains filtered or unexported fields }
func (*BaseOpt) GetDescZsh ¶
func (*BaseOpt) GetTitleFlagNames ¶
func (*BaseOpt) GetTitleFlagNamesBy ¶
func (*BaseOpt) GetTitleFlagNamesByMax ¶
func (*BaseOpt) GetTitleName ¶
func (*BaseOpt) GetTitleNames ¶
func (*BaseOpt) GetTitleNamesArray ¶
func (*BaseOpt) GetTitleNamesBy ¶
func (*BaseOpt) GetTitleZshFlagName ¶
func (*BaseOpt) GetTitleZshFlagNames ¶
func (*BaseOpt) GetTitleZshFlagNamesArray ¶
type Command ¶
type Command struct { BaseOpt SubCommands []*Command // return: ShouldBeStopException will break the following flow and exit right now PreAction func(cmd *Command, args []string) (err error) // PostAction will be run after Action() invoked. PostAction func(cmd *Command, args []string) // contains filtered or unexported fields }
func (*Command) GetExpandableNames ¶
func (*Command) GetExpandableNamesArray ¶
func (*Command) GetParentName ¶
func (*Command) GetQuotedGroupName ¶
func (*Command) GetRoot ¶
func (c *Command) GetRoot() *RootCommand
func (*Command) GetSubCommandNamesBy ¶
func (*Command) PrintVersion ¶
func (c *Command) PrintVersion()
type ConfigReloaded ¶
type ConfigReloaded interface {
OnConfigReloaded()
}
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func NewOptions ¶
func NewOptions() *Options
func NewOptionsWith ¶
func (*Options) DumpAsString ¶
func (*Options) Get ¶
Get an `Option` by key string, eg: ```golang cmdr.Get("app.logger.level") => 'DEBUG',... ```
func (*Options) GetStringSlice ¶
func (*Options) LoadConfigFile ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.