Documentation ¶
Index ¶
- Constants
- Variables
- func AddOnAfterXrefBuilt(cb HookXrefFunc)
- func AddOnBeforeXrefBuilding(cb HookXrefFunc)
- func AddOnConfigLoadedListener(c ConfigReloaded)
- func Clone(fromValue, toValue interface{}) interface{}
- func DumpAsString() (str string)
- func EnsureDir(dir string) (err error)
- func Exec(rootCmd *RootCommand) (err error)
- func ExecWith(rootCmd *RootCommand, beforeXrefBuildingX, afterXrefBuiltX HookXrefFunc) (err error)
- func FileExists(name string) bool
- func Get(key string) interface{}
- func GetBool(key string) bool
- func GetBoolP(prefix, key string) bool
- func GetCurrentDir() string
- func GetDebugMode() bool
- func GetDuration(key string) time.Duration
- func GetDurationP(prefix, key string) time.Duration
- func GetExcutableDir() string
- func GetExcutablePath() string
- func GetInt(key string) int
- func GetInt64(key string) int64
- func GetInt64P(prefix, key string) int64
- func GetIntP(prefix, key string) int
- func GetIntSlice(key string) []int
- func GetIntSliceP(prefix, key string) []int
- func GetPredefinedLocations() []string
- func GetQuietMode() bool
- func GetStrictMode() bool
- func GetString(key string) string
- func GetStringP(prefix, key string) string
- func GetStringSlice(key string) []string
- func GetStringSliceP(prefix, key string) []string
- func GetUint(key string) uint
- func GetUint64(key string) uint64
- func GetUint64P(prefix, key string) uint64
- func GetUintP(prefix, key string) uint
- func GetUsedConfigFile() string
- func GetUsedConfigSubDir() string
- func GetVerboseMode() bool
- func InTesting() bool
- func InternalExecFor(rootCmd *RootCommand, args []string) (err error)
- func Launch(cmd string, args ...string) (err error)
- func LaunchEditor(editor string) (content []byte, err error)
- func LaunchEditorWith(editor string, filename string) (content []byte, err error)
- func LoadConfigFile(file string) (err error)
- func NormalizeDir(s string) string
- func PrintBuildInfo()
- func RemoveOnConfigLoadedListener(c ConfigReloaded)
- func ResetOptions()
- func SaveAsJSON(filename string) (err error)
- func SaveAsToml(filename string) (err error)
- func SaveAsYaml(filename string) (err error)
- func SaveObjAsToml(obj interface{}, filename string) (err error)
- func Set(key string, val interface{})
- func SetCustomShowBuildInfo(fn func())
- func SetCustomShowVersion(fn func())
- func SetInternalOutputStreams(out, err *bufio.Writer)
- func SetNx(key string, val interface{})
- func SetOnConfigLoadedListener(c ConfigReloaded, enabled bool)
- func SetPredefinedLocations(locations []string)
- func StripOrderPrefix(s string) string
- func WalkAllCommands(walk func(cmd *Command, index int) (err error)) (err error)
- type BaseOpt
- func (s *BaseOpt) GetLongTitleNamesArray() []string
- func (s *BaseOpt) GetShortTitleNamesArray() []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) HasParent() bool
- type BoolOpt
- func (s *BoolOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *BoolOpt) Aliases(aliases ...string) (opt OptFlag)
- func (s *BoolOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *BoolOpt) Deprecated(deprecation string) (opt OptFlag)
- func (s *BoolOpt) Description(oneLine, long string) (opt OptFlag)
- func (s *BoolOpt) Examples(examples string) (opt OptFlag)
- func (s *BoolOpt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *BoolOpt) Group(group string) (opt OptFlag)
- func (s *BoolOpt) Hidden(hidden bool) (opt OptFlag)
- func (s *BoolOpt) Long(long string) (opt OptFlag)
- func (s *BoolOpt) OwnerCommand() (opt OptCmd)
- func (s *BoolOpt) RootCommand() (root *RootCommand)
- func (s *BoolOpt) SetOwner(opt OptCmd)
- func (s *BoolOpt) Short(short string) (opt OptFlag)
- func (s *BoolOpt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *BoolOpt) ToggleGroup(group string) (opt OptFlag)
- type CmdOpt
- func (s *CmdOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptCmd)
- func (s *CmdOpt) Aliases(aliases ...string) (opt OptCmd)
- func (s *CmdOpt) Bool() (opt OptFlag)
- func (s *CmdOpt) Deprecated(deprecation string) (opt OptCmd)
- func (s *CmdOpt) Description(oneLine, long string) (opt OptCmd)
- func (s *CmdOpt) Duration() (opt OptFlag)
- func (s *CmdOpt) Examples(examples string) (opt OptCmd)
- func (s *CmdOpt) Group(group string) (opt OptCmd)
- func (s *CmdOpt) Hidden(hidden bool) (opt OptCmd)
- func (s *CmdOpt) Int() (opt OptFlag)
- func (s *CmdOpt) Int64() (opt OptFlag)
- func (s *CmdOpt) IntSlice() (opt OptFlag)
- func (s *CmdOpt) Long(long string) (opt OptCmd)
- func (s *CmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)
- func (s *CmdOpt) NewSubCommand() (opt OptCmd)
- func (s *CmdOpt) OwnerCommand() (opt OptCmd)
- func (s *CmdOpt) PostAction(pre func(cmd *Command, args []string)) (opt OptCmd)
- func (s *CmdOpt) PreAction(pre func(cmd *Command, args []string) (err error)) (opt OptCmd)
- func (s *CmdOpt) RootCommand() (root *RootCommand)
- func (s *CmdOpt) SetOwner(opt OptCmd)
- func (s *CmdOpt) Short(short string) (opt OptCmd)
- func (s *CmdOpt) String() (opt OptFlag)
- func (s *CmdOpt) StringSlice() (opt OptFlag)
- func (s *CmdOpt) TailPlaceholder(placeholder string) (opt OptCmd)
- func (s *CmdOpt) Titles(short, long string, aliases ...string) (opt OptCmd)
- func (s *CmdOpt) Uint() (opt OptFlag)
- func (s *CmdOpt) Uint64() (opt OptFlag)
- type Command
- func (c *Command) GetExpandableNames() string
- func (c *Command) GetExpandableNamesArray() []string
- func (c *Command) GetHitStr() string
- func (c *Command) GetName() string
- func (c *Command) GetOwner() *Command
- 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) IsRoot() bool
- func (c *Command) PrintHelp(justFlags bool)
- func (c *Command) PrintVersion()
- type ConfigReloaded
- type Copier
- type CopierImpl
- type DurationOpt
- func (s *DurationOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *DurationOpt) Aliases(aliases ...string) (opt OptFlag)
- func (s *DurationOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *DurationOpt) Deprecated(deprecation string) (opt OptFlag)
- func (s *DurationOpt) Description(oneLine, long string) (opt OptFlag)
- func (s *DurationOpt) Examples(examples string) (opt OptFlag)
- func (s *DurationOpt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *DurationOpt) Group(group string) (opt OptFlag)
- func (s *DurationOpt) Hidden(hidden bool) (opt OptFlag)
- func (s *DurationOpt) Long(long string) (opt OptFlag)
- func (s *DurationOpt) OwnerCommand() (opt OptCmd)
- func (s *DurationOpt) RootCommand() (root *RootCommand)
- func (s *DurationOpt) SetOwner(opt OptCmd)
- func (s *DurationOpt) Short(short string) (opt OptFlag)
- func (s *DurationOpt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *DurationOpt) ToggleGroup(group string) (opt OptFlag)
- type Flag
- func (s *Flag) GetDescZsh() (desc string)
- func (s *Flag) GetTitleFlagNames() string
- func (s *Flag) GetTitleFlagNamesBy(delimChar string) string
- func (s *Flag) GetTitleFlagNamesByMax(delimChar string, maxCount int) string
- func (s *Flag) GetTitleZshFlagName() (str string)
- func (s *Flag) GetTitleZshFlagNames(delimChar string) (str string)
- func (s *Flag) GetTitleZshFlagNamesArray() (ary []string)
- type HookXrefFunc
- type Int64Opt
- func (s *Int64Opt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *Int64Opt) Aliases(aliases ...string) (opt OptFlag)
- func (s *Int64Opt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *Int64Opt) Deprecated(deprecation string) (opt OptFlag)
- func (s *Int64Opt) Description(oneLine, long string) (opt OptFlag)
- func (s *Int64Opt) Examples(examples string) (opt OptFlag)
- func (s *Int64Opt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *Int64Opt) Group(group string) (opt OptFlag)
- func (s *Int64Opt) Hidden(hidden bool) (opt OptFlag)
- func (s *Int64Opt) Long(long string) (opt OptFlag)
- func (s *Int64Opt) OwnerCommand() (opt OptCmd)
- func (s *Int64Opt) RootCommand() (root *RootCommand)
- func (s *Int64Opt) SetOwner(opt OptCmd)
- func (s *Int64Opt) Short(short string) (opt OptFlag)
- func (s *Int64Opt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *Int64Opt) ToggleGroup(group string) (opt OptFlag)
- type IntOpt
- func (s *IntOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *IntOpt) Aliases(aliases ...string) (opt OptFlag)
- func (s *IntOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *IntOpt) Deprecated(deprecation string) (opt OptFlag)
- func (s *IntOpt) Description(oneLine, long string) (opt OptFlag)
- func (s *IntOpt) Examples(examples string) (opt OptFlag)
- func (s *IntOpt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *IntOpt) Group(group string) (opt OptFlag)
- func (s *IntOpt) Hidden(hidden bool) (opt OptFlag)
- func (s *IntOpt) Long(long string) (opt OptFlag)
- func (s *IntOpt) OwnerCommand() (opt OptCmd)
- func (s *IntOpt) RootCommand() (root *RootCommand)
- func (s *IntOpt) SetOwner(opt OptCmd)
- func (s *IntOpt) Short(short string) (opt OptFlag)
- func (s *IntOpt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *IntOpt) ToggleGroup(group string) (opt OptFlag)
- type IntSliceOpt
- func (s *IntSliceOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *IntSliceOpt) Aliases(aliases ...string) (opt OptFlag)
- func (s *IntSliceOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *IntSliceOpt) Deprecated(deprecation string) (opt OptFlag)
- func (s *IntSliceOpt) Description(oneLine, long string) (opt OptFlag)
- func (s *IntSliceOpt) Examples(examples string) (opt OptFlag)
- func (s *IntSliceOpt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *IntSliceOpt) Group(group string) (opt OptFlag)
- func (s *IntSliceOpt) Hidden(hidden bool) (opt OptFlag)
- func (s *IntSliceOpt) Long(long string) (opt OptFlag)
- func (s *IntSliceOpt) OwnerCommand() (opt OptCmd)
- func (s *IntSliceOpt) RootCommand() (root *RootCommand)
- func (s *IntSliceOpt) SetOwner(opt OptCmd)
- func (s *IntSliceOpt) Short(short string) (opt OptFlag)
- func (s *IntSliceOpt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *IntSliceOpt) ToggleGroup(group string) (opt OptFlag)
- type Opt
- type OptCmd
- type OptFlag
- type OptFlagType
- 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) GetDuration(key string) (ir time.Duration)
- func (s *Options) GetHierarchyList() map[string]interface{}
- func (s *Options) GetInt(key string) (ir int64)
- func (s *Options) GetIntSlice(key string) (ir []int)
- func (s *Options) GetString(key string) (ret string)
- func (s *Options) GetStringSlice(key string) (ir []string)
- func (s *Options) GetUint(key string) (ir uint64)
- 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 Painter
- type RootCmdOpt
- func (s *RootCmdOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptCmd)
- func (s *RootCmdOpt) Aliases(aliases ...string) (opt OptCmd)
- func (s *RootCmdOpt) Bool() (opt OptFlag)
- func (s *RootCmdOpt) Copyright(copyright, author string) *RootCmdOpt
- func (s *RootCmdOpt) Deprecated(deprecation string) (opt OptCmd)
- func (s *RootCmdOpt) Description(oneLine, long string) (opt OptCmd)
- func (s *RootCmdOpt) Duration() (opt OptFlag)
- func (s *RootCmdOpt) Examples(examples string) (opt OptCmd)
- func (s *RootCmdOpt) Group(group string) (opt OptCmd)
- func (s *RootCmdOpt) Header(header string) *RootCmdOpt
- func (s *RootCmdOpt) Hidden(hidden bool) (opt OptCmd)
- func (s *RootCmdOpt) Int() (opt OptFlag)
- func (s *RootCmdOpt) Int64() (opt OptFlag)
- func (s *RootCmdOpt) IntSlice() (opt OptFlag)
- func (s *RootCmdOpt) Long(long string) (opt OptCmd)
- func (s *RootCmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)
- func (s *RootCmdOpt) NewSubCommand() (opt OptCmd)
- func (s *RootCmdOpt) OwnerCommand() (opt OptCmd)
- func (s *RootCmdOpt) PostAction(pre func(cmd *Command, args []string)) (opt OptCmd)
- func (s *RootCmdOpt) PreAction(pre func(cmd *Command, args []string) (err error)) (opt OptCmd)
- func (s *RootCmdOpt) RootCommand() (root *RootCommand)
- func (s *RootCmdOpt) SetOwner(opt OptCmd)
- func (s *RootCmdOpt) Short(short string) (opt OptCmd)
- func (s *RootCmdOpt) String() (opt OptFlag)
- func (s *RootCmdOpt) StringSlice() (opt OptFlag)
- func (s *RootCmdOpt) TailPlaceholder(placeholder string) (opt OptCmd)
- func (s *RootCmdOpt) Titles(short, long string, aliases ...string) (opt OptCmd)
- func (s *RootCmdOpt) Uint() (opt OptFlag)
- func (s *RootCmdOpt) Uint64() (opt OptFlag)
- type RootCommand
- type StringOpt
- func (s *StringOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *StringOpt) Aliases(aliases ...string) (opt OptFlag)
- func (s *StringOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *StringOpt) Deprecated(deprecation string) (opt OptFlag)
- func (s *StringOpt) Description(oneLine, long string) (opt OptFlag)
- func (s *StringOpt) Examples(examples string) (opt OptFlag)
- func (s *StringOpt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *StringOpt) Group(group string) (opt OptFlag)
- func (s *StringOpt) Hidden(hidden bool) (opt OptFlag)
- func (s *StringOpt) Long(long string) (opt OptFlag)
- func (s *StringOpt) OwnerCommand() (opt OptCmd)
- func (s *StringOpt) RootCommand() (root *RootCommand)
- func (s *StringOpt) SetOwner(opt OptCmd)
- func (s *StringOpt) Short(short string) (opt OptFlag)
- func (s *StringOpt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *StringOpt) ToggleGroup(group string) (opt OptFlag)
- type StringSliceOpt
- func (s *StringSliceOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *StringSliceOpt) Aliases(aliases ...string) (opt OptFlag)
- func (s *StringSliceOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *StringSliceOpt) Deprecated(deprecation string) (opt OptFlag)
- func (s *StringSliceOpt) Description(oneLine, long string) (opt OptFlag)
- func (s *StringSliceOpt) Examples(examples string) (opt OptFlag)
- func (s *StringSliceOpt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *StringSliceOpt) Group(group string) (opt OptFlag)
- func (s *StringSliceOpt) Hidden(hidden bool) (opt OptFlag)
- func (s *StringSliceOpt) Long(long string) (opt OptFlag)
- func (s *StringSliceOpt) OwnerCommand() (opt OptCmd)
- func (s *StringSliceOpt) RootCommand() (root *RootCommand)
- func (s *StringSliceOpt) SetOwner(opt OptCmd)
- func (s *StringSliceOpt) Short(short string) (opt OptFlag)
- func (s *StringSliceOpt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *StringSliceOpt) ToggleGroup(group string) (opt OptFlag)
- type SubCmdOpt
- func (s *SubCmdOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptCmd)
- func (s *SubCmdOpt) Aliases(aliases ...string) (opt OptCmd)
- func (s *SubCmdOpt) Bool() (opt OptFlag)
- func (s *SubCmdOpt) Deprecated(deprecation string) (opt OptCmd)
- func (s *SubCmdOpt) Description(oneLine, long string) (opt OptCmd)
- func (s *SubCmdOpt) Duration() (opt OptFlag)
- func (s *SubCmdOpt) Examples(examples string) (opt OptCmd)
- func (s *SubCmdOpt) Group(group string) (opt OptCmd)
- func (s *SubCmdOpt) Hidden(hidden bool) (opt OptCmd)
- func (s *SubCmdOpt) Int() (opt OptFlag)
- func (s *SubCmdOpt) Int64() (opt OptFlag)
- func (s *SubCmdOpt) IntSlice() (opt OptFlag)
- func (s *SubCmdOpt) Long(long string) (opt OptCmd)
- func (s *SubCmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)
- func (s *SubCmdOpt) NewSubCommand() (opt OptCmd)
- func (s *SubCmdOpt) OwnerCommand() (opt OptCmd)
- func (s *SubCmdOpt) PostAction(pre func(cmd *Command, args []string)) (opt OptCmd)
- func (s *SubCmdOpt) PreAction(pre func(cmd *Command, args []string) (err error)) (opt OptCmd)
- func (s *SubCmdOpt) RootCommand() (root *RootCommand)
- func (s *SubCmdOpt) SetOwner(opt OptCmd)
- func (s *SubCmdOpt) Short(short string) (opt OptCmd)
- func (s *SubCmdOpt) String() (opt OptFlag)
- func (s *SubCmdOpt) StringSlice() (opt OptFlag)
- func (s *SubCmdOpt) TailPlaceholder(placeholder string) (opt OptCmd)
- func (s *SubCmdOpt) Titles(short, long string, aliases ...string) (opt OptCmd)
- func (s *SubCmdOpt) Uint() (opt OptFlag)
- func (s *SubCmdOpt) Uint64() (opt OptFlag)
- type Uint64Opt
- func (s *Uint64Opt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *Uint64Opt) Aliases(aliases ...string) (opt OptFlag)
- func (s *Uint64Opt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *Uint64Opt) Deprecated(deprecation string) (opt OptFlag)
- func (s *Uint64Opt) Description(oneLine, long string) (opt OptFlag)
- func (s *Uint64Opt) Examples(examples string) (opt OptFlag)
- func (s *Uint64Opt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *Uint64Opt) Group(group string) (opt OptFlag)
- func (s *Uint64Opt) Hidden(hidden bool) (opt OptFlag)
- func (s *Uint64Opt) Long(long string) (opt OptFlag)
- func (s *Uint64Opt) OwnerCommand() (opt OptCmd)
- func (s *Uint64Opt) RootCommand() (root *RootCommand)
- func (s *Uint64Opt) SetOwner(opt OptCmd)
- func (s *Uint64Opt) Short(short string) (opt OptFlag)
- func (s *Uint64Opt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *Uint64Opt) ToggleGroup(group string) (opt OptFlag)
- type UintOpt
- func (s *UintOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)
- func (s *UintOpt) Aliases(aliases ...string) (opt OptFlag)
- func (s *UintOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)
- func (s *UintOpt) Deprecated(deprecation string) (opt OptFlag)
- func (s *UintOpt) Description(oneLine, long string) (opt OptFlag)
- func (s *UintOpt) Examples(examples string) (opt OptFlag)
- func (s *UintOpt) ExternalTool(envKeyName string) (opt OptFlag)
- func (s *UintOpt) Group(group string) (opt OptFlag)
- func (s *UintOpt) Hidden(hidden bool) (opt OptFlag)
- func (s *UintOpt) Long(long string) (opt OptFlag)
- func (s *UintOpt) OwnerCommand() (opt OptCmd)
- func (s *UintOpt) RootCommand() (root *RootCommand)
- func (s *UintOpt) SetOwner(opt OptCmd)
- func (s *UintOpt) Short(short string) (opt OptFlag)
- func (s *UintOpt) Titles(short, long string, aliases ...string) (opt OptFlag)
- func (s *UintOpt) ToggleGroup(group string) (opt OptFlag)
Constants ¶
const ( // UnsortedGroup for commands and flags UnsortedGroup = "zzzz.unsorted" // SysMgmtGroup for commands and flags SysMgmtGroup = "zzz9.Misc" // DefaultEditor is 'vim' DefaultEditor = "vim" // ExternalToolEditor environment variable name, EDITOR is fit for most of shells. ExternalToolEditor = "EDITOR" // ExternalToolPasswordInput enables secure password input without echo. ExternalToolPasswordInput = "PASSWD" )
const ( // AppName const AppName = "cmdr" // main app-name // Version const Version = "0.2.19" // version name // VersionInt const VersionInt = 0x0002019 // using as )
const ( // FgBlack terminal color code FgBlack = 30 // FgRed terminal color code FgRed = 31 // FgGreen terminal color code FgGreen = 32 // FgYellow terminal color code FgYellow = 33 // FgBlue terminal color code FgBlue = 34 // FgMagenta terminal color code FgMagenta = 35 // FgCyan terminal color code FgCyan = 36 // FgLightGray terminal color code FgLightGray = 37 // FgDarkGray terminal color code FgDarkGray = 90 // FgLightRed terminal color code FgLightRed = 91 // FgLightGreen terminal color code FgLightGreen = 92 // FgLightYellow terminal color code FgLightYellow = 93 // FgLightBlue terminal color code FgLightBlue = 94 // FgLightMagenta terminal color code FgLightMagenta = 95 // FgLightCyan terminal color code FgLightCyan = 96 // FgWhite terminal color code FgWhite = 97 // BgNormal terminal color code BgNormal = 0 // BgBoldOrBright terminal color code BgBoldOrBright = 1 // BgDim terminal color code BgDim = 2 // BgItalic terminal color code BgItalic = 3 // BgUnderline terminal color code BgUnderline = 4 // BgUlink terminal color code BgUlink = 5 // BgHidden terminal color code BgHidden = 8 // DarkColor terminal color code DarkColor = FgLightGray )
Variables ¶
var ( // GormDefaultCopier used for gorm GormDefaultCopier = &CopierImpl{true, true, true} // StandardCopier is a normal copier StandardCopier = &CopierImpl{false, false, false} )
var ( // EnableVersionCommands supports injecting the default `--version` flags and commands EnableVersionCommands = true // EnableHelpCommands supports injecting the default `--help` flags and commands EnableHelpCommands = true // EnableVerboseCommands supports injecting the default `--verbose` flags and commands EnableVerboseCommands = true // EnableCmdrCommands support these flags: `--strict-mode`, `--no-env-overrides` EnableCmdrCommands = true // EnableGenerateCommands supports injecting the default `generate` commands and subcommands EnableGenerateCommands = true // RxxtPrefix create a top-level namespace, which contains all normalized `Flag`s. RxxtPrefix = []string{"app"} // EnvPrefix attaches a prefix to key to retrieve the option value. EnvPrefix = []string{"CMDR"} // CurrentDescColor the print color for description line CurrentDescColor = FgDarkGray // CurrentDefaultValueColor the print color for default value line CurrentDefaultValueColor = FgDarkGray // CurrentGroupTitleColor the print color for titles CurrentGroupTitleColor = DarkColor // GetEditor sets callback to get editor program GetEditor func() (string, error) // ErrShouldBeStopException tips `Exec()` cancelled the following actions after `PreAction()` ErrShouldBeStopException = errors.New("should be stop right now") )
var SavedOsArgs []string
SavedOsArgs is a copy of os.Args, just for testing
Functions ¶
func AddOnAfterXrefBuilt ¶ added in v0.2.11
func AddOnAfterXrefBuilt(cb HookXrefFunc)
AddOnAfterXrefBuilt add hook func
func AddOnBeforeXrefBuilding ¶ added in v0.2.11
func AddOnBeforeXrefBuilding(cb HookXrefFunc)
AddOnBeforeXrefBuilding add hook func
func AddOnConfigLoadedListener ¶
func AddOnConfigLoadedListener(c ConfigReloaded)
AddOnConfigLoadedListener add an functor on config loaded and merged
func Clone ¶ added in v0.2.3
func Clone(fromValue, toValue interface{}) interface{}
Clone deep copy source to target
func ExecWith ¶ added in v0.2.11
func ExecWith(rootCmd *RootCommand, beforeXrefBuildingX, afterXrefBuiltX HookXrefFunc) (err error)
ExecWith is main entry of `cmdr`.
func FileExists ¶
FileExists returns the existence of an directory or file
func Get ¶
func Get(key string) interface{}
Get returns the generic value of an `Option` key. Such as: ```golang cmdr.Get("app.logger.level") => 'DEBUG',... ```
func GetCurrentDir ¶
func GetCurrentDir() string
GetCurrentDir returns the current workingFlag directory
func GetDebugMode ¶ added in v0.2.5
func GetDebugMode() bool
GetDebugMode returns the flag value of `--debug`/`-D`
func GetDuration ¶ added in v0.2.19
GetDuration returns the int slice value of an `Option` key.
func GetDurationP ¶ added in v0.2.19
GetDurationP returns the int slice value of an `Option` key.
func GetExcutableDir ¶
func GetExcutableDir() string
GetExcutableDir returns the executable file directory
func GetExcutablePath ¶ added in v0.2.13
func GetExcutablePath() string
GetExcutablePath returns the executable file path
func GetIntSlice ¶ added in v0.2.19
GetIntSlice returns the int slice value of an `Option` key.
func GetIntSliceP ¶ added in v0.2.19
GetIntSliceP returns the int slice value of an `Option` key.
func GetPredefinedLocations ¶ added in v0.2.5
func GetPredefinedLocations() []string
GetPredefinedLocations return the searching locations for loading config files.
func GetQuietMode ¶ added in v0.2.5
func GetQuietMode() bool
GetQuietMode returns the flag value of `--quiet`/`-q`
func GetStrictMode ¶ added in v0.2.5
func GetStrictMode() bool
GetStrictMode enables error when opt value missed. such as: xxx a b --prefix” => error: prefix opt has no value specified. xxx a b --prefix'/' => ok.
ENV: use `CMDR_APP_STRICT_MODE=true` to enable strict-mode. NOTE: `CMDR_APP_` prefix could be set by user (via: `EnvPrefix` && `RxxtPrefix`).
the flag value of `--strict-mode`.
func GetStringP ¶ added in v0.2.3
GetStringP returns the string value of an `Option` key.
func GetStringSlice ¶
GetStringSlice returns the string slice value of an `Option` key.
func GetStringSliceP ¶ added in v0.2.3
GetStringSliceP returns the string slice value of an `Option` key.
func GetUint64P ¶ added in v0.2.3
GetUint64P returns the uint64 value of an `Option` key.
func GetUsedConfigFile ¶ added in v0.2.3
func GetUsedConfigFile() string
GetUsedConfigFile returns the main config filename (generally it's `<appname>.yml`)
func GetUsedConfigSubDir ¶ added in v0.2.3
func GetUsedConfigSubDir() string
GetUsedConfigSubDir returns the sub-directory `conf.d` of config files
func GetVerboseMode ¶ added in v0.2.5
func GetVerboseMode() bool
GetVerboseMode returns the flag value of `--verbose`/`-v`
func InTesting ¶ added in v0.2.19
func InTesting() bool
InTesting detects whether is running under go test mode
func InternalExecFor ¶ added in v0.2.3
func InternalExecFor(rootCmd *RootCommand, args []string) (err error)
InternalExecFor is an internal helper, esp for debugging
func Launch ¶ added in v0.2.13
Launch executes a command setting both standard input, output and error.
func LaunchEditor ¶ added in v0.2.13
LaunchEditor launches the specified editor
func LaunchEditorWith ¶ added in v0.2.19
LaunchEditor launches the specified editor with a filename
func LoadConfigFile ¶
LoadConfigFile Load a yaml config file and merge the settings into `rxxtOptions` and load files in the `conf.d` child directory too.
func NormalizeDir ¶ added in v0.2.19
NormalizeDir make dir name normalized
func PrintBuildInfo ¶ added in v0.2.19
func PrintBuildInfo()
PrintBuildInfo print building information
func RemoveOnConfigLoadedListener ¶
func RemoveOnConfigLoadedListener(c ConfigReloaded)
RemoveOnConfigLoadedListener remove an functor on config loaded and merged
func ResetOptions ¶ added in v0.2.19
func ResetOptions()
Reset the exists `Options`, so that you could follow a `LoadConfigFile()` with it.
func SaveAsJSON ¶ added in v0.2.17
SaveAsJSON to Save all config entries as a json file
func SaveAsToml ¶ added in v0.2.17
SaveAsToml to Save all config entries as a toml file
func SaveAsYaml ¶ added in v0.2.17
SaveAsYaml to Save all config entries as a yaml file
func SaveObjAsToml ¶ added in v0.2.19
SaveObjAsToml to Save an object as a toml file
func Set ¶ added in v0.2.3
func Set(key string, val interface{})
Set set the value of an `Option` key (with prefix auto-wrap). ```golang cmdr.Set("logger.level", "DEBUG") cmdr.Set("ms.tags.port", 8500) ... ```
func SetCustomShowBuildInfo ¶ added in v0.2.3
func SetCustomShowBuildInfo(fn func())
SetCustomShowBuildInfo supports your `ShowBuildInfo()` instead of internal `showBuildInfo()`
func SetCustomShowVersion ¶ added in v0.2.3
func SetCustomShowVersion(fn func())
SetCustomShowVersion supports your `ShowVersion()` instead of internal `showVersion()`
func SetInternalOutputStreams ¶ added in v0.2.3
SetInternalOutputStreams sets the internal output streams for debugging
func SetNx ¶ added in v0.2.3
func SetNx(key string, val interface{})
SetNx but without prefix auto-wrapped. `rxxtPrefix` is a string slice to define the prefix string array, default is ["app"]. So, cmdr.Set("debug", true) will put an real entry with (`app.debug`, true).
func SetOnConfigLoadedListener ¶
func SetOnConfigLoadedListener(c ConfigReloaded, enabled bool)
SetOnConfigLoadedListener enable/disable an functor on config loaded and merged
func SetPredefinedLocations ¶ added in v0.2.5
func SetPredefinedLocations(locations []string)
SetPredefinedLocations to customize the searching locations for loading config files. It MUST be invoked before `cmdr.Exec`. Such as: ```go
SetPredefinedLocations([]string{"./config", "~/.config/cmdr/", "$GOPATH/running-configs/cmdr"})
```
func StripOrderPrefix ¶ added in v0.2.9
StripOrderPrefix strips the prefix string fragment for sorting order. see also: Command.Group, Flag.Group, ...
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 Description string LongDescription string Examples string Hidden bool // Deprecated is a version string just like '0.5.9', that means this command/flag was/will be deprecated since `v0.5.9`. Deprecated string // Action is callback for the last recognized command/sub-command. // return: ErrShouldBeStopException will break the following flow and exit right now // cmd 是 flag 被识别时已经得到的子命令 Action func(cmd *Command, args []string) (err error) // contains filtered or unexported fields }
BaseOpt is base of `Command`, `Flag`
func (*BaseOpt) GetLongTitleNamesArray ¶ added in v0.2.3
GetLongTitleNamesArray returns long name and aliases as an array
func (*BaseOpt) GetShortTitleNamesArray ¶ added in v0.2.3
GetShortTitleNamesArray returns short name as an array
func (*BaseOpt) GetTitleName ¶
GetTitleName returns name/full/short string
func (*BaseOpt) GetTitleNames ¶
GetTitleNames return the joint string of short,full,aliases names
func (*BaseOpt) GetTitleNamesArray ¶
GetTitleNamesArray returns short,full,aliases names
func (*BaseOpt) GetTitleNamesBy ¶
GetTitleNamesBy returns the joint string of short,full,aliases names
type BoolOpt ¶ added in v0.2.15
type BoolOpt struct {
// contains filtered or unexported fields
}
BoolOpt for fluent api
func (*BoolOpt) DefaultValue ¶ added in v0.2.15
func (*BoolOpt) Deprecated ¶ added in v0.2.15
func (*BoolOpt) Description ¶ added in v0.2.15
func (*BoolOpt) ExternalTool ¶ added in v0.2.15
func (*BoolOpt) OwnerCommand ¶ added in v0.2.15
func (s *BoolOpt) OwnerCommand() (opt OptCmd)
func (*BoolOpt) RootCommand ¶ added in v0.2.15
func (s *BoolOpt) RootCommand() (root *RootCommand)
func (*BoolOpt) ToggleGroup ¶ added in v0.2.15
type CmdOpt ¶ added in v0.2.15
type CmdOpt struct {
// contains filtered or unexported fields
}
CmdOpt for fluent api
func (*CmdOpt) Deprecated ¶ added in v0.2.15
func (*CmdOpt) Description ¶ added in v0.2.15
func (*CmdOpt) NewFlag ¶ added in v0.2.15
func (s *CmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)
func (*CmdOpt) NewSubCommand ¶ added in v0.2.15
func (s *CmdOpt) NewSubCommand() (opt OptCmd)
func (*CmdOpt) OwnerCommand ¶ added in v0.2.15
func (s *CmdOpt) OwnerCommand() (opt OptCmd)
func (*CmdOpt) PostAction ¶ added in v0.2.15
func (*CmdOpt) RootCommand ¶ added in v0.2.15
func (s *CmdOpt) RootCommand() (root *RootCommand)
func (*CmdOpt) StringSlice ¶ added in v0.2.15
func (s *CmdOpt) StringSlice() (opt OptFlag)
func (*CmdOpt) TailPlaceholder ¶ added in v0.2.15
type Command ¶
type Command struct { BaseOpt Flags []*Flag SubCommands []*Command // return: ErrShouldBeStopException 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) // be shown at tail of command usages line. Such as for TailPlaceHolder="<host-fqdn> <ipv4/6>": // austr dns add <host-fqdn> <ipv4/6> [Options] [Parent/Global Options] TailPlaceHolder string // contains filtered or unexported fields }
Command holds the structure of commands and subcommands
func FindSubCommand ¶ added in v0.2.17
FindSubCommand find sub-command with `longName` from `cmd`
func FindSubCommandRecursive ¶ added in v0.2.17
FindSubCommandRecursive find sub-command with `longName` from `cmd` recursively
func (*Command) GetExpandableNames ¶
GetExpandableNames returns the names comma splitted string.
func (*Command) GetExpandableNamesArray ¶
GetExpandableNamesArray returns the names array of command, includes short name and long name.
func (*Command) GetParentName ¶
GetParentName returns the owner command name
func (*Command) GetQuotedGroupName ¶
GetQuotedGroupName returns the group name quoted string.
func (*Command) GetRoot ¶
func (c *Command) GetRoot() *RootCommand
GetRoot returns the `RootCommand`
func (*Command) GetSubCommandNamesBy ¶
GetSubCommandNamesBy returns the joint string of subcommands
func (*Command) PrintVersion ¶
func (c *Command) PrintVersion()
PrintVersion prints versions information
type ConfigReloaded ¶
type ConfigReloaded interface {
OnConfigReloaded()
}
ConfigReloaded for config reloaded
type Copier ¶ added in v0.2.3
type Copier interface {
Copy(toValue interface{}, fromValue interface{}, ignoreNames ...string) (err error)
}
Copier interface Copier is based on from github.com/jinzhu/copier
type CopierImpl ¶ added in v0.2.3
type CopierImpl struct { KeepIfFromIsNil bool // 源字段值为nil指针时,目标字段的值保持不变 ZeroIfEqualsFrom bool // 源和目标字段值相同时,目标字段被清除为未初始化的零值 KeepIfFromIsZero bool // 源字段值为未初始化的零值时,目标字段的值保持不变 // 此条尚未实现 }
CopierImpl impl
func (*CopierImpl) Copy ¶ added in v0.2.3
func (s *CopierImpl) Copy(toValue interface{}, fromValue interface{}, ignoreNames ...string) (err error)
Copy copy things
type DurationOpt ¶ added in v0.2.17
type DurationOpt struct {
// contains filtered or unexported fields
}
DurationOpt for fluent api
func (*DurationOpt) DefaultValue ¶ added in v0.2.17
func (*DurationOpt) Deprecated ¶ added in v0.2.17
func (*DurationOpt) Description ¶ added in v0.2.17
func (*DurationOpt) ExternalTool ¶ added in v0.2.17
func (*DurationOpt) OwnerCommand ¶ added in v0.2.17
func (s *DurationOpt) OwnerCommand() (opt OptCmd)
func (*DurationOpt) RootCommand ¶ added in v0.2.17
func (s *DurationOpt) RootCommand() (root *RootCommand)
func (*DurationOpt) ToggleGroup ¶ added in v0.2.17
type Flag ¶
type Flag struct { BaseOpt // ToggleGroup: to-do: Toggle Group ToggleGroup string // DefaultValuePlaceholder for flag DefaultValuePlaceholder string // DefaultValue default value for flag DefaultValue interface{} // ValidArgs to-do ValidArgs []string // Required to-do Required bool // ExternalTool to get the value text by invoking external tool // It's an environment variable name, such as: "EDITOR" (or cmdr.ExternalToolEditor) ExternalTool string // PostAction treat this flag as a command! PostAction func(cmd *Command, args []string) (err error) }
Flag means a flag, a option, or a opt.
func FindFlagRecursive ¶ added in v0.2.17
FindFlagRecursive find flag with `longName` from `cmd` recursively
func (*Flag) GetDescZsh ¶ added in v0.2.13
GetDescZsh temp
func (*Flag) GetTitleFlagNames ¶ added in v0.2.13
GetTitleFlagNames temp
func (*Flag) GetTitleFlagNamesBy ¶ added in v0.2.13
GetTitleFlagNamesBy temp
func (*Flag) GetTitleFlagNamesByMax ¶ added in v0.2.13
GetTitleFlagNamesByMax temp
func (*Flag) GetTitleZshFlagName ¶ added in v0.2.13
GetTitleZshFlagName temp
func (*Flag) GetTitleZshFlagNames ¶ added in v0.2.13
GetTitleZshFlagNames temp
func (*Flag) GetTitleZshFlagNamesArray ¶ added in v0.2.13
GetTitleZshFlagNamesArray temp
type HookXrefFunc ¶ added in v0.2.11
type HookXrefFunc func(root *RootCommand, args []string)
HookXrefFunc the hook function prototype for SetBeforeXrefBuilding and SetAfterXrefBuilt
type Int64Opt ¶ added in v0.2.15
type Int64Opt struct {
// contains filtered or unexported fields
}
Int64Opt for fluent api
func (*Int64Opt) DefaultValue ¶ added in v0.2.15
func (*Int64Opt) Deprecated ¶ added in v0.2.15
func (*Int64Opt) Description ¶ added in v0.2.15
func (*Int64Opt) ExternalTool ¶ added in v0.2.15
func (*Int64Opt) OwnerCommand ¶ added in v0.2.15
func (s *Int64Opt) OwnerCommand() (opt OptCmd)
func (*Int64Opt) RootCommand ¶ added in v0.2.15
func (s *Int64Opt) RootCommand() (root *RootCommand)
func (*Int64Opt) ToggleGroup ¶ added in v0.2.15
type IntOpt ¶ added in v0.2.15
type IntOpt struct {
// contains filtered or unexported fields
}
IntOpt for fluent api
func (*IntOpt) DefaultValue ¶ added in v0.2.15
func (*IntOpt) Deprecated ¶ added in v0.2.15
func (*IntOpt) Description ¶ added in v0.2.15
func (*IntOpt) ExternalTool ¶ added in v0.2.15
func (*IntOpt) OwnerCommand ¶ added in v0.2.15
func (s *IntOpt) OwnerCommand() (opt OptCmd)
func (*IntOpt) RootCommand ¶ added in v0.2.15
func (s *IntOpt) RootCommand() (root *RootCommand)
func (*IntOpt) ToggleGroup ¶ added in v0.2.15
type IntSliceOpt ¶ added in v0.2.15
type IntSliceOpt struct {
// contains filtered or unexported fields
}
IntSliceOpt for fluent api
func (*IntSliceOpt) DefaultValue ¶ added in v0.2.15
func (*IntSliceOpt) Deprecated ¶ added in v0.2.15
func (*IntSliceOpt) Description ¶ added in v0.2.15
func (*IntSliceOpt) ExternalTool ¶ added in v0.2.15
func (*IntSliceOpt) OwnerCommand ¶ added in v0.2.15
func (s *IntSliceOpt) OwnerCommand() (opt OptCmd)
func (*IntSliceOpt) RootCommand ¶ added in v0.2.15
func (s *IntSliceOpt) RootCommand() (root *RootCommand)
func (*IntSliceOpt) ToggleGroup ¶ added in v0.2.15
type Opt ¶ added in v0.2.15
type Opt interface { Titles(short, long string, aliases ...string) (opt Opt) Short(short string) (opt Opt) Long(long string) (opt Opt) Aliases(ss ...string) (opt Opt) Description(oneLine, long string) (opt Opt) Examples(examples string) (opt Opt) Group(group string) (opt Opt) Hidden(hidden bool) (opt Opt) Deprecated(deprecation string) (opt Opt) Action(action func(cmd *Command, args []string) (err error)) (opt Opt) }
Opt never used?
type OptCmd ¶ added in v0.2.15
type OptCmd interface { Titles(short, long string, aliases ...string) (opt OptCmd) Short(short string) (opt OptCmd) Long(long string) (opt OptCmd) Aliases(ss ...string) (opt OptCmd) Description(oneLine, long string) (opt OptCmd) Examples(examples string) (opt OptCmd) Group(group string) (opt OptCmd) Hidden(hidden bool) (opt OptCmd) Deprecated(deprecation string) (opt OptCmd) Action(action func(cmd *Command, args []string) (err error)) (opt OptCmd) // FlagAdd(flg *Flag) (opt OptCmd) // SubCommand(cmd *Command) (opt OptCmd) PreAction(pre func(cmd *Command, args []string) (err error)) (opt OptCmd) PostAction(post func(cmd *Command, args []string)) (opt OptCmd) TailPlaceholder(placeholder string) (opt OptCmd) NewFlag(typ OptFlagType) (opt OptFlag) NewSubCommand() (opt OptCmd) OwnerCommand() (opt OptCmd) SetOwner(opt OptCmd) RootCommand() *RootCommand }
OptCmd to support fluent api of cmdr. see also: cmdr.Root().NewSubCommand()/.NewFlag()
func NewCmdFrom ¶ added in v0.2.17
NewCmdFrom for fluent api
type OptFlag ¶ added in v0.2.15
type OptFlag interface { Titles(short, long string, aliases ...string) (opt OptFlag) Short(short string) (opt OptFlag) Long(long string) (opt OptFlag) Aliases(ss ...string) (opt OptFlag) Description(oneLine, long string) (opt OptFlag) Examples(examples string) (opt OptFlag) Group(group string) (opt OptFlag) Hidden(hidden bool) (opt OptFlag) Deprecated(deprecation string) (opt OptFlag) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag) ToggleGroup(group string) (opt OptFlag) DefaultValue(val interface{}, placeholder string) (opt OptFlag) ExternalTool(envKeyName string) (opt OptFlag) OwnerCommand() (opt OptCmd) SetOwner(opt OptCmd) RootCommand() *RootCommand }
OptFlag to support fluent api of cmdr. see also: cmdr.Root().NewSubCommand()/.NewFlag()
func NewStringSlice ¶ added in v0.2.17
func NewStringSlice() (opt OptFlag)
NewStringSlice for fluent api
type OptFlagType ¶ added in v0.2.15
type OptFlagType int
OptFlagType to support fluent api of cmdr. see also: OptCmd.NewFlag(OptFlagType) usage: ```golang root := cmdr.Root() co := root.NewSubCommand() co.NewFlag(cmdr.OptFlagTypeUint) ```
const ( // OptFlagTypeBool to create a new bool flag OptFlagTypeBool OptFlagType = iota // OptFlagTypeInt to create a new int flag OptFlagTypeInt OptFlagType = iota + 1 // OptFlagTypeUint to create a new uint flag OptFlagTypeUint OptFlagType = iota + 2 // OptFlagTypeInt64 to create a new int64 flag OptFlagTypeInt64 OptFlagType = iota + 3 // OptFlagTypeUint64 to create a new uint64 flag OptFlagTypeUint64 OptFlagType = iota + 4 // OptFlagTypeString to create a new string flag OptFlagTypeString OptFlagType = iota + 5 // OptFlagTypeStringSlice to create a new string slice flag OptFlagTypeStringSlice OptFlagType = iota + 6 // OptFlagTypeIntSlice to create a new int slice flag OptFlagTypeIntSlice OptFlagType = iota + 7 // OptFlagTypeDuration to create a new duration flag OptFlagTypeDuration OptFlagType = iota + 8 )
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is a holder of all options
func NewOptionsWith ¶
NewOptionsWith returns an `Options` structure pointer
func (*Options) DumpAsString ¶
DumpAsString for debugging.
func (*Options) Get ¶
Get an `Option` by key string, eg: ```golang cmdr.Get("app.logger.level") => 'DEBUG',... ```
func (*Options) GetDuration ¶ added in v0.2.11
GetDuration returns the time duration value of an `Option` key.
func (*Options) GetHierarchyList ¶ added in v0.2.17
GetHierarchyList returns the hierarchy data for dumping
func (*Options) GetIntSlice ¶ added in v0.2.11
GetIntSlice returns the string slice value of an `Option` key.
func (*Options) GetStringSlice ¶
GetStringSlice returns the string slice value of an `Option` key.
func (*Options) LoadConfigFile ¶
LoadConfigFile Load a yaml config file and merge the settings into `rxxtOptions` and load files in the `conf.d` child directory too.
func (*Options) Reset ¶
func (s *Options) Reset()
Reset the exists `Options`, so that you could follow a `LoadConfigFile()` with it.
type Painter ¶ added in v0.2.9
type Painter interface { Printf(fmtStr string, args ...interface{}) FpPrintHeader(command *Command) FpPrintHelpTailLine(command *Command) FpUsagesTitle(command *Command, title string) FpUsagesLine(command *Command, fmt, appName, cmdList, cmdsTitle, tailPlaceHolder string) FpDescTitle(command *Command, title string) FpDescLine(command *Command) FpExamplesTitle(command *Command, title string) FpExamplesLine(command *Command) FpCommandsTitle(command *Command) FpCommandsGroupTitle(group string) FpCommandsLine(command *Command) FpFlagsTitle(command *Command, flag *Flag, title string) FpFlagsGroupTitle(group string) FpFlagsLine(command *Command, flag *Flag, defValStr string) Flush() Results() []byte // clear any internal states and reset itself Reset() }
Painter to support the genManual, genMarkdown, printHelpScreen.
type RootCmdOpt ¶ added in v0.2.15
type RootCmdOpt struct {
// contains filtered or unexported fields
}
RootCmdOpt for fluent api
func Root ¶ added in v0.2.15
func Root(appName, version string) (opt *RootCmdOpt)
Root for fluent api, create an new RootCommand
func (*RootCmdOpt) Copyright ¶ added in v0.2.15
func (s *RootCmdOpt) Copyright(copyright, author string) *RootCmdOpt
Copyright for fluent api
func (*RootCmdOpt) Deprecated ¶ added in v0.2.15
func (*RootCmdOpt) Description ¶ added in v0.2.15
func (*RootCmdOpt) Header ¶ added in v0.2.15
func (s *RootCmdOpt) Header(header string) *RootCmdOpt
Header for fluent api
func (*RootCmdOpt) NewFlag ¶ added in v0.2.15
func (s *RootCmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)
func (*RootCmdOpt) NewSubCommand ¶ added in v0.2.15
func (s *RootCmdOpt) NewSubCommand() (opt OptCmd)
func (*RootCmdOpt) OwnerCommand ¶ added in v0.2.15
func (s *RootCmdOpt) OwnerCommand() (opt OptCmd)
func (*RootCmdOpt) PostAction ¶ added in v0.2.15
func (*RootCmdOpt) RootCommand ¶ added in v0.2.15
func (s *RootCmdOpt) RootCommand() (root *RootCommand)
func (*RootCmdOpt) StringSlice ¶ added in v0.2.15
func (s *RootCmdOpt) StringSlice() (opt OptFlag)
func (*RootCmdOpt) TailPlaceholder ¶ added in v0.2.15
type RootCommand ¶
type RootCommand struct { Command AppName string Version string VersionInt uint32 Copyright string Author string Header string // using `Header` for header and ignore built with `Copyright` and `Author`, and no usage lines too. // contains filtered or unexported fields }
RootCommand holds some application information
type StringOpt ¶ added in v0.2.15
type StringOpt struct {
// contains filtered or unexported fields
}
StringOpt for fluent api
func (*StringOpt) DefaultValue ¶ added in v0.2.15
func (*StringOpt) Deprecated ¶ added in v0.2.15
func (*StringOpt) Description ¶ added in v0.2.15
func (*StringOpt) ExternalTool ¶ added in v0.2.15
func (*StringOpt) OwnerCommand ¶ added in v0.2.15
func (s *StringOpt) OwnerCommand() (opt OptCmd)
func (*StringOpt) RootCommand ¶ added in v0.2.15
func (s *StringOpt) RootCommand() (root *RootCommand)
func (*StringOpt) ToggleGroup ¶ added in v0.2.15
type StringSliceOpt ¶ added in v0.2.15
type StringSliceOpt struct {
// contains filtered or unexported fields
}
StringSliceOpt for fluent api
func (*StringSliceOpt) DefaultValue ¶ added in v0.2.15
func (*StringSliceOpt) Deprecated ¶ added in v0.2.15
func (*StringSliceOpt) Description ¶ added in v0.2.15
func (*StringSliceOpt) ExternalTool ¶ added in v0.2.15
func (*StringSliceOpt) OwnerCommand ¶ added in v0.2.15
func (s *StringSliceOpt) OwnerCommand() (opt OptCmd)
func (*StringSliceOpt) RootCommand ¶ added in v0.2.15
func (s *StringSliceOpt) RootCommand() (root *RootCommand)
func (*StringSliceOpt) ToggleGroup ¶ added in v0.2.15
type SubCmdOpt ¶ added in v0.2.15
type SubCmdOpt struct {
// contains filtered or unexported fields
}
SubCmdOpt for fluent api
func (*SubCmdOpt) Deprecated ¶ added in v0.2.15
func (*SubCmdOpt) Description ¶ added in v0.2.15
func (*SubCmdOpt) NewFlag ¶ added in v0.2.15
func (s *SubCmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)
func (*SubCmdOpt) NewSubCommand ¶ added in v0.2.15
func (s *SubCmdOpt) NewSubCommand() (opt OptCmd)
func (*SubCmdOpt) OwnerCommand ¶ added in v0.2.15
func (s *SubCmdOpt) OwnerCommand() (opt OptCmd)
func (*SubCmdOpt) PostAction ¶ added in v0.2.15
func (*SubCmdOpt) RootCommand ¶ added in v0.2.15
func (s *SubCmdOpt) RootCommand() (root *RootCommand)
func (*SubCmdOpt) StringSlice ¶ added in v0.2.15
func (s *SubCmdOpt) StringSlice() (opt OptFlag)
func (*SubCmdOpt) TailPlaceholder ¶ added in v0.2.15
type Uint64Opt ¶ added in v0.2.15
type Uint64Opt struct {
// contains filtered or unexported fields
}
Uint64Opt for fluent api
func (*Uint64Opt) DefaultValue ¶ added in v0.2.15
func (*Uint64Opt) Deprecated ¶ added in v0.2.15
func (*Uint64Opt) Description ¶ added in v0.2.15
func (*Uint64Opt) ExternalTool ¶ added in v0.2.15
func (*Uint64Opt) OwnerCommand ¶ added in v0.2.15
func (s *Uint64Opt) OwnerCommand() (opt OptCmd)
func (*Uint64Opt) RootCommand ¶ added in v0.2.15
func (s *Uint64Opt) RootCommand() (root *RootCommand)
func (*Uint64Opt) ToggleGroup ¶ added in v0.2.15
type UintOpt ¶ added in v0.2.15
type UintOpt struct {
// contains filtered or unexported fields
}
UintOpt for fluent api
func (*UintOpt) DefaultValue ¶ added in v0.2.15
func (*UintOpt) Deprecated ¶ added in v0.2.15
func (*UintOpt) Description ¶ added in v0.2.15
func (*UintOpt) ExternalTool ¶ added in v0.2.15
func (*UintOpt) OwnerCommand ¶ added in v0.2.15
func (s *UintOpt) OwnerCommand() (opt OptCmd)
func (*UintOpt) RootCommand ¶ added in v0.2.15
func (s *UintOpt) RootCommand() (root *RootCommand)
func (*UintOpt) ToggleGroup ¶ added in v0.2.15
Source Files ¶
- base_opt.go
- build_xref.go
- clone.go
- command.go
- def.go
- dir.go
- doc.go
- exec.go
- flag.go
- generate_cmds.go
- generate_shell.go
- opt.go
- opt_command_impl.go
- opt_flag_impl.go
- opt_ops.go
- options.go
- options.watch.go
- print.go
- print_painter.go
- print_painter_help.go
- print_painter_man.go
- print_painter_mkd.go
- tool.go
- whitespaces.go