cmdr: github.com/hedzr/cmdr Index | Files | Directories

package cmdr

import "github.com/hedzr/cmdr"

Index

Package Files

base_opt.go build_xref.go clone.go command.go def.go dir.go doc.go exec.go exec_match.go exec_unknown.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_colors.go print_painter.go print_painter_help.go print_painter_man.go print_painter_mkd.go print_tree.go tool.go walk.go whitespaces.go

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.25" // version name
    // VersionInt const
    VersionInt = 0x000219 // 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

func AddOnAfterXrefBuilt Uses

func AddOnAfterXrefBuilt(cb HookXrefFunc)

AddOnAfterXrefBuilt add hook func

func AddOnBeforeXrefBuilding Uses

func AddOnBeforeXrefBuilding(cb HookXrefFunc)

AddOnBeforeXrefBuilding add hook func

func AddOnConfigLoadedListener Uses

func AddOnConfigLoadedListener(c ConfigReloaded)

AddOnConfigLoadedListener add an functor on config loaded and merged

func Clone Uses

func Clone(fromValue, toValue interface{}) interface{}

Clone deep copy source to target

func DumpAsString Uses

func DumpAsString() (str string)

DumpAsString for debugging.

func EnsureDir Uses

func EnsureDir(dir string) (err error)

EnsureDir checks and creates the directory.

func Exec Uses

func Exec(rootCmd *RootCommand) (err error)

Exec is main entry of `cmdr`.

func ExecWith Uses

func ExecWith(rootCmd *RootCommand, beforeXrefBuildingX, afterXrefBuiltX HookXrefFunc) (err error)

ExecWith is main entry of `cmdr`.

func FileExists Uses

func FileExists(name string) bool

FileExists returns the existence of an directory or file

func Get Uses

func Get(key string) interface{}

Get returns the generic value of an `Option` key with [WrapWithRxxtPrefix]. Such as: “`golang cmdr.Get("app.logger.level") => 'DEBUG',... “`

func GetBool Uses

func GetBool(key string) bool

GetBool returns the bool value of an `Option` key. Such as: “`golang cmdr.Get("app.logger.enable") => true,... “`

func GetBoolP Uses

func GetBoolP(prefix, key string) bool

GetBoolP returns the bool value of an `Option` key. Such as: “`golang cmdr.GetP("app.logger", "enable") => true,... “`

func GetBoolR Uses

func GetBoolR(key string) bool

GetBoolR returns the bool value of an `Option` key with [WrapWithRxxtPrefix]. Such as: “`golang cmdr.GetBoolR("logger.enable") => true,... “`

func GetBoolRP Uses

func GetBoolRP(prefix, key string) bool

GetBoolRP returns the bool value of an `Option` key with [WrapWithRxxtPrefix]. Such as: “`golang cmdr.GetBoolRP("logger", "enable") => true,... “`

func GetCurrentDir Uses

func GetCurrentDir() string

GetCurrentDir returns the current workingFlag directory

func GetDebugMode Uses

func GetDebugMode() bool

GetDebugMode returns the flag value of `--debug`/`-D`

func GetDuration Uses

func GetDuration(key string) time.Duration

GetDuration returns the int slice value of an `Option` key.

func GetDurationP Uses

func GetDurationP(prefix, key string) time.Duration

GetDurationP returns the int slice value of an `Option` key.

func GetDurationR Uses

func GetDurationR(key string) time.Duration

GetDurationR returns the int slice value of an `Option` key.

func GetDurationRP Uses

func GetDurationRP(prefix, key string) time.Duration

GetDurationRP returns the int slice value of an `Option` key.

func GetExcutableDir Uses

func GetExcutableDir() string

GetExcutableDir returns the executable file directory

func GetExcutablePath Uses

func GetExcutablePath() string

GetExcutablePath returns the executable file path

func GetInt Uses

func GetInt(key string) int

GetInt returns the int value of an `Option` key.

func GetInt64 Uses

func GetInt64(key string) int64

GetInt64 returns the int64 value of an `Option` key.

func GetInt64P Uses

func GetInt64P(prefix, key string) int64

GetInt64P returns the int64 value of an `Option` key.

func GetInt64R Uses

func GetInt64R(key string) int64

GetInt64R returns the int64 value of an `Option` key with [WrapWithRxxtPrefix].

func GetInt64RP Uses

func GetInt64RP(prefix, key string) int64

GetInt64RP returns the int64 value of an `Option` key with [WrapWithRxxtPrefix].

func GetIntP Uses

func GetIntP(prefix, key string) int

GetIntP returns the int value of an `Option` key.

func GetIntR Uses

func GetIntR(key string) int

GetIntR returns the int value of an `Option` key with [WrapWithRxxtPrefix].

func GetIntRP Uses

func GetIntRP(prefix, key string) int

GetIntRP returns the int value of an `Option` key with [WrapWithRxxtPrefix].

func GetIntSlice Uses

func GetIntSlice(key string) []int

GetIntSlice returns the int slice value of an `Option` key.

func GetIntSliceP Uses

func GetIntSliceP(prefix, key string) []int

GetIntSliceP returns the int slice value of an `Option` key.

func GetIntSliceR Uses

func GetIntSliceR(key string) []int

GetIntSliceR returns the int slice value of an `Option` key with [WrapWithRxxtPrefix].

func GetIntSliceRP Uses

func GetIntSliceRP(prefix, key string) []int

GetIntSliceRP returns the int slice value of an `Option` key with [WrapWithRxxtPrefix].

func GetMap Uses

func GetMap(key string) map[string]interface{}

GetMap an `Option` by key string, it returns a hierarchy map or nil

func GetMapR Uses

func GetMapR(key string) map[string]interface{}

GetMapR an `Option` by key string with [WrapWithRxxtPrefix], it returns a hierarchy map or nil

func GetPredefinedLocations Uses

func GetPredefinedLocations() []string

GetPredefinedLocations return the searching locations for loading config files.

func GetQuietMode Uses

func GetQuietMode() bool

GetQuietMode returns the flag value of `--quiet`/`-q`

func GetR Uses

func GetR(key string) interface{}

GetR returns the generic value of an `Option` key with [WrapWithRxxtPrefix]. Such as: “`golang cmdr.GetR("logger.level") => 'DEBUG',... “`

func GetStrictMode Uses

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 GetString Uses

func GetString(key string) string

GetString returns the string value of an `Option` key.

func GetStringP Uses

func GetStringP(prefix, key string) string

GetStringP returns the string value of an `Option` key.

func GetStringR Uses

func GetStringR(key string) string

GetStringR returns the string value of an `Option` key with [WrapWithRxxtPrefix].

func GetStringRP Uses

func GetStringRP(prefix, key string) string

GetStringRP returns the string value of an `Option` key with [WrapWithRxxtPrefix].

func GetStringSlice Uses

func GetStringSlice(key string) []string

GetStringSlice returns the string slice value of an `Option` key.

func GetStringSliceP Uses

func GetStringSliceP(prefix, key string) []string

GetStringSliceP returns the string slice value of an `Option` key.

func GetStringSliceR Uses

func GetStringSliceR(key string) []string

GetStringSliceR returns the string slice value of an `Option` key with [WrapWithRxxtPrefix].

func GetStringSliceRP Uses

func GetStringSliceRP(prefix, key string) []string

GetStringSliceRP returns the string slice value of an `Option` key with [WrapWithRxxtPrefix].

func GetUint Uses

func GetUint(key string) uint

GetUint returns the uint value of an `Option` key.

func GetUint64 Uses

func GetUint64(key string) uint64

GetUint64 returns the uint64 value of an `Option` key.

func GetUint64P Uses

func GetUint64P(prefix, key string) uint64

GetUint64P returns the uint64 value of an `Option` key.

func GetUint64R Uses

func GetUint64R(key string) uint64

GetUint64R returns the uint64 value of an `Option` key with [WrapWithRxxtPrefix].

func GetUint64RP Uses

func GetUint64RP(prefix, key string) uint64

GetUint64RP returns the uint64 value of an `Option` key with [WrapWithRxxtPrefix].

func GetUintP Uses

func GetUintP(prefix, key string) uint

GetUintP returns the uint value of an `Option` key.

func GetUintR Uses

func GetUintR(key string) uint

GetUintR returns the uint value of an `Option` key with [WrapWithRxxtPrefix].

func GetUintRP Uses

func GetUintRP(prefix, key string) uint

GetUintRP returns the uint value of an `Option` key with [WrapWithRxxtPrefix].

func GetUsedConfigFile Uses

func GetUsedConfigFile() string

GetUsedConfigFile returns the main config filename (generally it's `<appname>.yml`)

func GetUsedConfigSubDir Uses

func GetUsedConfigSubDir() string

GetUsedConfigSubDir returns the sub-directory `conf.d` of config files

func GetVerboseMode Uses

func GetVerboseMode() bool

GetVerboseMode returns the flag value of `--verbose`/`-v`

func InTesting Uses

func InTesting() bool

InTesting detects whether is running under go test mode

func InternalExecFor Uses

func InternalExecFor(rootCmd *RootCommand, args []string) (err error)

InternalExecFor is an internal helper, esp for debugging

func IsDirectory Uses

func IsDirectory(path string) (bool, error)

IsDirectory tests whether `path` is a directory or not

func IsRegularFile Uses

func IsRegularFile(path string) (bool, error)

IsRegularFile tests whether `path` is a normal regular file or not

func Launch Uses

func Launch(cmd string, args ...string) (err error)

Launch executes a command setting both standard input, output and error.

func LaunchEditor Uses

func LaunchEditor(editor string) (content []byte, err error)

LaunchEditor launches the specified editor

func LaunchEditorWith Uses

func LaunchEditorWith(editor string, filename string) (content []byte, err error)

LaunchEditorWith launches the specified editor with a filename

func LoadConfigFile Uses

func LoadConfigFile(file string) (err error)

LoadConfigFile Load a yaml config file and merge the settings into `rxxtOptions` and load files in the `conf.d` child directory too.

func NormalizeDir Uses

func NormalizeDir(s string) string

NormalizeDir make dir name normalized

func PrintBuildInfo Uses

func PrintBuildInfo()

PrintBuildInfo print building information

func RemoveOnConfigLoadedListener Uses

func RemoveOnConfigLoadedListener(c ConfigReloaded)

RemoveOnConfigLoadedListener remove an functor on config loaded and merged

func ResetOptions Uses

func ResetOptions()

ResetOptions to reset the exists `Options`, so that you could follow a `LoadConfigFile()` with it.

func SaveAsJSON Uses

func SaveAsJSON(filename string) (err error)

SaveAsJSON to Save all config entries as a json file

func SaveAsToml Uses

func SaveAsToml(filename string) (err error)

SaveAsToml to Save all config entries as a toml file

func SaveAsYaml Uses

func SaveAsYaml(filename string) (err error)

SaveAsYaml to Save all config entries as a yaml file

func SaveObjAsToml Uses

func SaveObjAsToml(obj interface{}, filename string) (err error)

SaveObjAsToml to Save an object as a toml file

func Set Uses

func Set(key string, val interface{})

Set set the value of an `Option` key (with prefix auto-wrap). The key MUST not have an `app` prefix. eg: “`golang cmdr.Set("logger.level", "DEBUG") cmdr.Set("ms.tags.port", 8500) ... cmdr.Set("debug", true) cmdr.GetBool("app.debug") => true “`

func SetCurrentHelpPainter Uses

func SetCurrentHelpPainter(painter Painter)

SetCurrentHelpPainter allows to change the behavior and facade of help screen.

func SetCustomShowBuildInfo Uses

func SetCustomShowBuildInfo(fn func())

SetCustomShowBuildInfo supports your `ShowBuildInfo()` instead of internal `showBuildInfo()`

func SetCustomShowVersion Uses

func SetCustomShowVersion(fn func())

SetCustomShowVersion supports your `ShowVersion()` instead of internal `showVersion()`

func SetHelpTabStop Uses

func SetHelpTabStop(tabStop int)

SetHelpTabStop sets the tab stop for help screen output

func SetInternalOutputStreams Uses

func SetInternalOutputStreams(out, err *bufio.Writer)

SetInternalOutputStreams sets the internal output streams for debugging

func SetNoLoadConfigFiles Uses

func SetNoLoadConfigFiles(b bool)

SetNoLoadConfigFiles true means no loading config files

func SetNx Uses

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 Uses

func SetOnConfigLoadedListener(c ConfigReloaded, enabled bool)

SetOnConfigLoadedListener enable/disable an functor on config loaded and merged

func SetPredefinedLocations Uses

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 SetUnknownOptionHandler Uses

func SetUnknownOptionHandler(handler func(isFlag bool, title string, cmd *Command, args []string))

SetUnknownOptionHandler enables your customized wrong command/flag processor. internal processor supports smart suggestions for those wrong commands and flags.

func Soundex Uses

func Soundex(s string) (snd4 string)

Soundex returns the english word's soundex value, such as: 'tags' => 't322'

func StripOrderPrefix Uses

func StripOrderPrefix(s string) string

StripOrderPrefix strips the prefix string fragment for sorting order. see also: Command.Group, Flag.Group, ...

func WalkAllCommands Uses

func WalkAllCommands(walk func(cmd *Command, index int) (err error)) (err error)

WalkAllCommands loops for all commands, starting from root.

func WrapWithRxxtPrefix Uses

func WrapWithRxxtPrefix(key string) string

WrapWithRxxtPrefix wrap an key with [RxxtPrefix], for [GetXxx(key)] and [GetXxxP(prefix,key)]

type BaseOpt Uses

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 Uses

func (s *BaseOpt) GetLongTitleNamesArray() []string

GetLongTitleNamesArray returns long name and aliases as an array

func (*BaseOpt) GetShortTitleNamesArray Uses

func (s *BaseOpt) GetShortTitleNamesArray() []string

GetShortTitleNamesArray returns short name as an array

func (*BaseOpt) GetTitleName Uses

func (s *BaseOpt) GetTitleName() string

GetTitleName returns name/full/short string

func (*BaseOpt) GetTitleNames Uses

func (s *BaseOpt) GetTitleNames() string

GetTitleNames return the joint string of short,full,aliases names

func (*BaseOpt) GetTitleNamesArray Uses

func (s *BaseOpt) GetTitleNamesArray() []string

GetTitleNamesArray returns short,full,aliases names

func (*BaseOpt) GetTitleNamesBy Uses

func (s *BaseOpt) GetTitleNamesBy(delimChar string) string

GetTitleNamesBy returns the joint string of short,full,aliases names

func (*BaseOpt) HasParent Uses

func (s *BaseOpt) HasParent() bool

HasParent detects whether owner is available or not

type BoolOpt Uses

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

BoolOpt for fluent api

func (*BoolOpt) Action Uses

func (s *BoolOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*BoolOpt) Aliases Uses

func (s *BoolOpt) Aliases(aliases ...string) (opt OptFlag)

func (*BoolOpt) DefaultValue Uses

func (s *BoolOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*BoolOpt) Deprecated Uses

func (s *BoolOpt) Deprecated(deprecation string) (opt OptFlag)

func (*BoolOpt) Description Uses

func (s *BoolOpt) Description(oneLine, long string) (opt OptFlag)

func (*BoolOpt) Examples Uses

func (s *BoolOpt) Examples(examples string) (opt OptFlag)

func (*BoolOpt) ExternalTool Uses

func (s *BoolOpt) ExternalTool(envKeyName string) (opt OptFlag)

func (*BoolOpt) Group Uses

func (s *BoolOpt) Group(group string) (opt OptFlag)

func (*BoolOpt) Hidden Uses

func (s *BoolOpt) Hidden(hidden bool) (opt OptFlag)

func (*BoolOpt) Long Uses

func (s *BoolOpt) Long(long string) (opt OptFlag)

func (*BoolOpt) OwnerCommand Uses

func (s *BoolOpt) OwnerCommand() (opt OptCmd)

func (*BoolOpt) RootCommand Uses

func (s *BoolOpt) RootCommand() (root *RootCommand)

func (*BoolOpt) SetOwner Uses

func (s *BoolOpt) SetOwner(opt OptCmd)

func (*BoolOpt) Short Uses

func (s *BoolOpt) Short(short string) (opt OptFlag)

func (*BoolOpt) Titles Uses

func (s *BoolOpt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*BoolOpt) ToggleGroup Uses

func (s *BoolOpt) ToggleGroup(group string) (opt OptFlag)

type CmdOpt Uses

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

CmdOpt for fluent api

func (*CmdOpt) Action Uses

func (s *CmdOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptCmd)

func (*CmdOpt) Aliases Uses

func (s *CmdOpt) Aliases(aliases ...string) (opt OptCmd)

func (*CmdOpt) Bool Uses

func (s *CmdOpt) Bool() (opt OptFlag)

func (*CmdOpt) Deprecated Uses

func (s *CmdOpt) Deprecated(deprecation string) (opt OptCmd)

func (*CmdOpt) Description Uses

func (s *CmdOpt) Description(oneLine, long string) (opt OptCmd)

func (*CmdOpt) Duration Uses

func (s *CmdOpt) Duration() (opt OptFlag)

func (*CmdOpt) Examples Uses

func (s *CmdOpt) Examples(examples string) (opt OptCmd)

func (*CmdOpt) Group Uses

func (s *CmdOpt) Group(group string) (opt OptCmd)

func (*CmdOpt) Hidden Uses

func (s *CmdOpt) Hidden(hidden bool) (opt OptCmd)

func (*CmdOpt) Int Uses

func (s *CmdOpt) Int() (opt OptFlag)

func (*CmdOpt) Int64 Uses

func (s *CmdOpt) Int64() (opt OptFlag)

func (*CmdOpt) IntSlice Uses

func (s *CmdOpt) IntSlice() (opt OptFlag)

func (*CmdOpt) Long Uses

func (s *CmdOpt) Long(long string) (opt OptCmd)

func (*CmdOpt) NewFlag Uses

func (s *CmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)

func (*CmdOpt) NewSubCommand Uses

func (s *CmdOpt) NewSubCommand() (opt OptCmd)

func (*CmdOpt) OwnerCommand Uses

func (s *CmdOpt) OwnerCommand() (opt OptCmd)

func (*CmdOpt) PostAction Uses

func (s *CmdOpt) PostAction(pre func(cmd *Command, args []string)) (opt OptCmd)

func (*CmdOpt) PreAction Uses

func (s *CmdOpt) PreAction(pre func(cmd *Command, args []string) (err error)) (opt OptCmd)

func (*CmdOpt) RootCommand Uses

func (s *CmdOpt) RootCommand() (root *RootCommand)

func (*CmdOpt) SetOwner Uses

func (s *CmdOpt) SetOwner(opt OptCmd)

func (*CmdOpt) Short Uses

func (s *CmdOpt) Short(short string) (opt OptCmd)

func (*CmdOpt) String Uses

func (s *CmdOpt) String() (opt OptFlag)

func (*CmdOpt) StringSlice Uses

func (s *CmdOpt) StringSlice() (opt OptFlag)

func (*CmdOpt) TailPlaceholder Uses

func (s *CmdOpt) TailPlaceholder(placeholder string) (opt OptCmd)

func (*CmdOpt) Titles Uses

func (s *CmdOpt) Titles(short, long string, aliases ...string) (opt OptCmd)

func (*CmdOpt) Uint Uses

func (s *CmdOpt) Uint() (opt OptFlag)

func (*CmdOpt) Uint64 Uses

func (s *CmdOpt) Uint64() (opt OptFlag)

type Command Uses

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 Uses

func FindSubCommand(longName string, cmd *Command) (res *Command)

FindSubCommand find sub-command with `longName` from `cmd`

func FindSubCommandRecursive Uses

func FindSubCommandRecursive(longName string, cmd *Command) (res *Command)

FindSubCommandRecursive find sub-command with `longName` from `cmd` recursively

func (*Command) GetExpandableNames Uses

func (c *Command) GetExpandableNames() string

GetExpandableNames returns the names comma splitted string.

func (*Command) GetExpandableNamesArray Uses

func (c *Command) GetExpandableNamesArray() []string

GetExpandableNamesArray returns the names array of command, includes short name and long name.

func (*Command) GetHitStr Uses

func (c *Command) GetHitStr() string

GetHitStr returns the matched command string

func (*Command) GetName Uses

func (c *Command) GetName() string

GetName returns the name of a `Command`.

func (*Command) GetOwner Uses

func (c *Command) GetOwner() *Command

GetOwner returns the parent command object

func (*Command) GetParentName Uses

func (c *Command) GetParentName() string

GetParentName returns the owner command name

func (*Command) GetQuotedGroupName Uses

func (c *Command) GetQuotedGroupName() string

GetQuotedGroupName returns the group name quoted string.

func (*Command) GetRoot Uses

func (c *Command) GetRoot() *RootCommand

GetRoot returns the `RootCommand`

func (*Command) GetSubCommandNamesBy Uses

func (c *Command) GetSubCommandNamesBy(delimChar string) string

GetSubCommandNamesBy returns the joint string of subcommands

func (*Command) IsRoot Uses

func (c *Command) IsRoot() bool

IsRoot returns true if this command is a RootCommand

func (*Command) PrintHelp Uses

func (c *Command) PrintHelp(justFlags bool)

PrintHelp prints help screen

func (*Command) PrintVersion Uses

func (c *Command) PrintVersion()

PrintVersion prints versions information

type ConfigReloaded Uses

type ConfigReloaded interface {
    OnConfigReloaded()
}

ConfigReloaded for config reloaded

type Copier Uses

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 Uses

type CopierImpl struct {
    KeepIfFromIsNil  bool // 源字段值为nil指针时,目标字段的值保持不变
    ZeroIfEqualsFrom bool // 源和目标字段值相同时,目标字段被清除为未初始化的零值
    KeepIfFromIsZero bool // 源字段值为未初始化的零值时,目标字段的值保持不变 // 此条尚未实现
}

CopierImpl impl

func (*CopierImpl) Copy Uses

func (s *CopierImpl) Copy(toValue interface{}, fromValue interface{}, ignoreNames ...string) (err error)

Copy copy things

type DurationOpt Uses

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

DurationOpt for fluent api

func (*DurationOpt) Action Uses

func (s *DurationOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*DurationOpt) Aliases Uses

func (s *DurationOpt) Aliases(aliases ...string) (opt OptFlag)

func (*DurationOpt) DefaultValue Uses

func (s *DurationOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*DurationOpt) Deprecated Uses

func (s *DurationOpt) Deprecated(deprecation string) (opt OptFlag)

func (*DurationOpt) Description Uses

func (s *DurationOpt) Description(oneLine, long string) (opt OptFlag)

func (*DurationOpt) Examples Uses

func (s *DurationOpt) Examples(examples string) (opt OptFlag)

func (*DurationOpt) ExternalTool Uses

func (s *DurationOpt) ExternalTool(envKeyName string) (opt OptFlag)

func (*DurationOpt) Group Uses

func (s *DurationOpt) Group(group string) (opt OptFlag)

func (*DurationOpt) Hidden Uses

func (s *DurationOpt) Hidden(hidden bool) (opt OptFlag)

func (*DurationOpt) Long Uses

func (s *DurationOpt) Long(long string) (opt OptFlag)

func (*DurationOpt) OwnerCommand Uses

func (s *DurationOpt) OwnerCommand() (opt OptCmd)

func (*DurationOpt) RootCommand Uses

func (s *DurationOpt) RootCommand() (root *RootCommand)

func (*DurationOpt) SetOwner Uses

func (s *DurationOpt) SetOwner(opt OptCmd)

func (*DurationOpt) Short Uses

func (s *DurationOpt) Short(short string) (opt OptFlag)

func (*DurationOpt) Titles Uses

func (s *DurationOpt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*DurationOpt) ToggleGroup Uses

func (s *DurationOpt) ToggleGroup(group string) (opt OptFlag)

type Flag Uses

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 FindFlag Uses

func FindFlag(longName string, cmd *Command) (res *Flag)

FindFlag find flag with `longName` from `cmd`

func FindFlagRecursive Uses

func FindFlagRecursive(longName string, cmd *Command) (res *Flag)

FindFlagRecursive find flag with `longName` from `cmd` recursively

func (*Flag) GetDescZsh Uses

func (s *Flag) GetDescZsh() (desc string)

GetDescZsh temp

func (*Flag) GetTitleFlagNames Uses

func (s *Flag) GetTitleFlagNames() string

GetTitleFlagNames temp

func (*Flag) GetTitleFlagNamesBy Uses

func (s *Flag) GetTitleFlagNamesBy(delimChar string) string

GetTitleFlagNamesBy temp

func (*Flag) GetTitleFlagNamesByMax Uses

func (s *Flag) GetTitleFlagNamesByMax(delimChar string, maxCount int) string

GetTitleFlagNamesByMax temp

func (*Flag) GetTitleZshFlagName Uses

func (s *Flag) GetTitleZshFlagName() (str string)

GetTitleZshFlagName temp

func (*Flag) GetTitleZshFlagNames Uses

func (s *Flag) GetTitleZshFlagNames(delimChar string) (str string)

GetTitleZshFlagNames temp

func (*Flag) GetTitleZshFlagNamesArray Uses

func (s *Flag) GetTitleZshFlagNamesArray() (ary []string)

GetTitleZshFlagNamesArray temp

type HookXrefFunc Uses

type HookXrefFunc func(root *RootCommand, args []string)

HookXrefFunc the hook function prototype for SetBeforeXrefBuilding and SetAfterXrefBuilt

type Int64Opt Uses

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

Int64Opt for fluent api

func (*Int64Opt) Action Uses

func (s *Int64Opt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*Int64Opt) Aliases Uses

func (s *Int64Opt) Aliases(aliases ...string) (opt OptFlag)

func (*Int64Opt) DefaultValue Uses

func (s *Int64Opt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*Int64Opt) Deprecated Uses

func (s *Int64Opt) Deprecated(deprecation string) (opt OptFlag)

func (*Int64Opt) Description Uses

func (s *Int64Opt) Description(oneLine, long string) (opt OptFlag)

func (*Int64Opt) Examples Uses

func (s *Int64Opt) Examples(examples string) (opt OptFlag)

func (*Int64Opt) ExternalTool Uses

func (s *Int64Opt) ExternalTool(envKeyName string) (opt OptFlag)

func (*Int64Opt) Group Uses

func (s *Int64Opt) Group(group string) (opt OptFlag)

func (*Int64Opt) Hidden Uses

func (s *Int64Opt) Hidden(hidden bool) (opt OptFlag)

func (*Int64Opt) Long Uses

func (s *Int64Opt) Long(long string) (opt OptFlag)

func (*Int64Opt) OwnerCommand Uses

func (s *Int64Opt) OwnerCommand() (opt OptCmd)

func (*Int64Opt) RootCommand Uses

func (s *Int64Opt) RootCommand() (root *RootCommand)

func (*Int64Opt) SetOwner Uses

func (s *Int64Opt) SetOwner(opt OptCmd)

func (*Int64Opt) Short Uses

func (s *Int64Opt) Short(short string) (opt OptFlag)

func (*Int64Opt) Titles Uses

func (s *Int64Opt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*Int64Opt) ToggleGroup Uses

func (s *Int64Opt) ToggleGroup(group string) (opt OptFlag)

type IntOpt Uses

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

IntOpt for fluent api

func (*IntOpt) Action Uses

func (s *IntOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*IntOpt) Aliases Uses

func (s *IntOpt) Aliases(aliases ...string) (opt OptFlag)

func (*IntOpt) DefaultValue Uses

func (s *IntOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*IntOpt) Deprecated Uses

func (s *IntOpt) Deprecated(deprecation string) (opt OptFlag)

func (*IntOpt) Description Uses

func (s *IntOpt) Description(oneLine, long string) (opt OptFlag)

func (*IntOpt) Examples Uses

func (s *IntOpt) Examples(examples string) (opt OptFlag)

func (*IntOpt) ExternalTool Uses

func (s *IntOpt) ExternalTool(envKeyName string) (opt OptFlag)

func (*IntOpt) Group Uses

func (s *IntOpt) Group(group string) (opt OptFlag)

func (*IntOpt) Hidden Uses

func (s *IntOpt) Hidden(hidden bool) (opt OptFlag)

func (*IntOpt) Long Uses

func (s *IntOpt) Long(long string) (opt OptFlag)

func (*IntOpt) OwnerCommand Uses

func (s *IntOpt) OwnerCommand() (opt OptCmd)

func (*IntOpt) RootCommand Uses

func (s *IntOpt) RootCommand() (root *RootCommand)

func (*IntOpt) SetOwner Uses

func (s *IntOpt) SetOwner(opt OptCmd)

func (*IntOpt) Short Uses

func (s *IntOpt) Short(short string) (opt OptFlag)

func (*IntOpt) Titles Uses

func (s *IntOpt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*IntOpt) ToggleGroup Uses

func (s *IntOpt) ToggleGroup(group string) (opt OptFlag)

type IntSliceOpt Uses

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

IntSliceOpt for fluent api

func (*IntSliceOpt) Action Uses

func (s *IntSliceOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*IntSliceOpt) Aliases Uses

func (s *IntSliceOpt) Aliases(aliases ...string) (opt OptFlag)

func (*IntSliceOpt) DefaultValue Uses

func (s *IntSliceOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*IntSliceOpt) Deprecated Uses

func (s *IntSliceOpt) Deprecated(deprecation string) (opt OptFlag)

func (*IntSliceOpt) Description Uses

func (s *IntSliceOpt) Description(oneLine, long string) (opt OptFlag)

func (*IntSliceOpt) Examples Uses

func (s *IntSliceOpt) Examples(examples string) (opt OptFlag)

func (*IntSliceOpt) ExternalTool Uses

func (s *IntSliceOpt) ExternalTool(envKeyName string) (opt OptFlag)

func (*IntSliceOpt) Group Uses

func (s *IntSliceOpt) Group(group string) (opt OptFlag)

func (*IntSliceOpt) Hidden Uses

func (s *IntSliceOpt) Hidden(hidden bool) (opt OptFlag)

func (*IntSliceOpt) Long Uses

func (s *IntSliceOpt) Long(long string) (opt OptFlag)

func (*IntSliceOpt) OwnerCommand Uses

func (s *IntSliceOpt) OwnerCommand() (opt OptCmd)

func (*IntSliceOpt) RootCommand Uses

func (s *IntSliceOpt) RootCommand() (root *RootCommand)

func (*IntSliceOpt) SetOwner Uses

func (s *IntSliceOpt) SetOwner(opt OptCmd)

func (*IntSliceOpt) Short Uses

func (s *IntSliceOpt) Short(short string) (opt OptFlag)

func (*IntSliceOpt) Titles Uses

func (s *IntSliceOpt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*IntSliceOpt) ToggleGroup Uses

func (s *IntSliceOpt) ToggleGroup(group string) (opt OptFlag)

type Opt Uses

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 Uses

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 NewCmd Uses

func NewCmd() (opt OptCmd)

NewCmd for fluent api

func NewCmdFrom Uses

func NewCmdFrom(cmd *Command) (opt OptCmd)

NewCmdFrom for fluent api

func NewSubCmd Uses

func NewSubCmd() (opt OptCmd)

NewSubCmd for fluent api

type OptFlag Uses

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 NewBool Uses

func NewBool() (opt OptFlag)

NewBool for fluent api

func NewDuration Uses

func NewDuration() (opt OptFlag)

NewDuration for fluent api

func NewInt Uses

func NewInt() (opt OptFlag)

NewInt for fluent api

func NewInt64 Uses

func NewInt64() (opt OptFlag)

NewInt64 for fluent api

func NewIntSlice Uses

func NewIntSlice() (opt OptFlag)

NewIntSlice for fluent api

func NewString Uses

func NewString() (opt OptFlag)

NewString for fluent api

func NewStringSlice Uses

func NewStringSlice() (opt OptFlag)

NewStringSlice for fluent api

func NewUint Uses

func NewUint() (opt OptFlag)

NewUint for fluent api

func NewUint64 Uses

func NewUint64() (opt OptFlag)

NewUint64 for fluent api

type OptFlagType Uses

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 Uses

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

Options is a holder of all options

func NewOptions Uses

func NewOptions() *Options

NewOptions returns an `Options` structure pointer

func NewOptionsWith Uses

func NewOptionsWith(entries map[string]interface{}) *Options

NewOptionsWith returns an `Options` structure pointer

func (*Options) DumpAsString Uses

func (s *Options) DumpAsString() (str string)

DumpAsString for debugging.

func (*Options) Get Uses

func (s *Options) Get(key string) interface{}

Get an `Option` by key string, eg: “`golang cmdr.Get("app.logger.level") => 'DEBUG',... “`

func (*Options) GetBool Uses

func (s *Options) GetBool(key string) (ret bool)

GetBool returns the bool value of an `Option` key.

func (*Options) GetDuration Uses

func (s *Options) GetDuration(key string) (ir time.Duration)

GetDuration returns the time duration value of an `Option` key.

func (*Options) GetHierarchyList Uses

func (s *Options) GetHierarchyList() map[string]interface{}

GetHierarchyList returns the hierarchy data for dumping

func (*Options) GetInt Uses

func (s *Options) GetInt(key string) (ir int64)

GetInt returns the int64 value of an `Option` key.

func (*Options) GetIntSlice Uses

func (s *Options) GetIntSlice(key string) (ir []int)

GetIntSlice returns the string slice value of an `Option` key.

func (*Options) GetMap Uses

func (s *Options) GetMap(key string) map[string]interface{}

GetMap an `Option` by key string, it returns a hierarchy map or nil

func (*Options) GetString Uses

func (s *Options) GetString(key string) (ret string)

GetString returns the string value of an `Option` key.

func (*Options) GetStringSlice Uses

func (s *Options) GetStringSlice(key string) (ir []string)

GetStringSlice returns the string slice value of an `Option` key.

func (*Options) GetUint Uses

func (s *Options) GetUint(key string) (ir uint64)

GetUint returns the uint64 value of an `Option` key.

func (*Options) LoadConfigFile Uses

func (s *Options) LoadConfigFile(file string) (err error)

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 Uses

func (s *Options) Reset()

Reset the exists `Options`, so that you could follow a `LoadConfigFile()` with it.

func (*Options) Set Uses

func (s *Options) Set(key string, val interface{})

Set set the value of an `Option` key. The key MUST not have an `app` prefix. eg: “`golang cmdr.Set("debug", true) cmdr.GetBool("app.debug") => true “`

func (*Options) SetNx Uses

func (s *Options) 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).

type Painter Uses

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 Uses

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

RootCmdOpt for fluent api

func Root Uses

func Root(appName, version string) (opt *RootCmdOpt)

Root for fluent api, create an new RootCommand

func (*RootCmdOpt) Action Uses

func (s *RootCmdOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptCmd)

func (*RootCmdOpt) Aliases Uses

func (s *RootCmdOpt) Aliases(aliases ...string) (opt OptCmd)

func (*RootCmdOpt) Bool Uses

func (s *RootCmdOpt) Bool() (opt OptFlag)

func (*RootCmdOpt) Copyright Uses

func (s *RootCmdOpt) Copyright(copyright, author string) *RootCmdOpt

Copyright for fluent api

func (*RootCmdOpt) Deprecated Uses

func (s *RootCmdOpt) Deprecated(deprecation string) (opt OptCmd)

func (*RootCmdOpt) Description Uses

func (s *RootCmdOpt) Description(oneLine, long string) (opt OptCmd)

func (*RootCmdOpt) Duration Uses

func (s *RootCmdOpt) Duration() (opt OptFlag)

func (*RootCmdOpt) Examples Uses

func (s *RootCmdOpt) Examples(examples string) (opt OptCmd)

func (*RootCmdOpt) Group Uses

func (s *RootCmdOpt) Group(group string) (opt OptCmd)

func (*RootCmdOpt) Header Uses

func (s *RootCmdOpt) Header(header string) *RootCmdOpt

Header for fluent api

func (*RootCmdOpt) Hidden Uses

func (s *RootCmdOpt) Hidden(hidden bool) (opt OptCmd)

func (*RootCmdOpt) Int Uses

func (s *RootCmdOpt) Int() (opt OptFlag)

func (*RootCmdOpt) Int64 Uses

func (s *RootCmdOpt) Int64() (opt OptFlag)

func (*RootCmdOpt) IntSlice Uses

func (s *RootCmdOpt) IntSlice() (opt OptFlag)

func (*RootCmdOpt) Long Uses

func (s *RootCmdOpt) Long(long string) (opt OptCmd)

func (*RootCmdOpt) NewFlag Uses

func (s *RootCmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)

func (*RootCmdOpt) NewSubCommand Uses

func (s *RootCmdOpt) NewSubCommand() (opt OptCmd)

func (*RootCmdOpt) OwnerCommand Uses

func (s *RootCmdOpt) OwnerCommand() (opt OptCmd)

func (*RootCmdOpt) PostAction Uses

func (s *RootCmdOpt) PostAction(pre func(cmd *Command, args []string)) (opt OptCmd)

func (*RootCmdOpt) PreAction Uses

func (s *RootCmdOpt) PreAction(pre func(cmd *Command, args []string) (err error)) (opt OptCmd)

func (*RootCmdOpt) RootCommand Uses

func (s *RootCmdOpt) RootCommand() (root *RootCommand)

func (*RootCmdOpt) SetOwner Uses

func (s *RootCmdOpt) SetOwner(opt OptCmd)

func (*RootCmdOpt) Short Uses

func (s *RootCmdOpt) Short(short string) (opt OptCmd)

func (*RootCmdOpt) String Uses

func (s *RootCmdOpt) String() (opt OptFlag)

func (*RootCmdOpt) StringSlice Uses

func (s *RootCmdOpt) StringSlice() (opt OptFlag)

func (*RootCmdOpt) TailPlaceholder Uses

func (s *RootCmdOpt) TailPlaceholder(placeholder string) (opt OptCmd)

func (*RootCmdOpt) Titles Uses

func (s *RootCmdOpt) Titles(short, long string, aliases ...string) (opt OptCmd)

func (*RootCmdOpt) Uint Uses

func (s *RootCmdOpt) Uint() (opt OptFlag)

func (*RootCmdOpt) Uint64 Uses

func (s *RootCmdOpt) Uint64() (opt OptFlag)

type RootCommand Uses

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 Uses

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

StringOpt for fluent api

func (*StringOpt) Action Uses

func (s *StringOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*StringOpt) Aliases Uses

func (s *StringOpt) Aliases(aliases ...string) (opt OptFlag)

func (*StringOpt) DefaultValue Uses

func (s *StringOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*StringOpt) Deprecated Uses

func (s *StringOpt) Deprecated(deprecation string) (opt OptFlag)

func (*StringOpt) Description Uses

func (s *StringOpt) Description(oneLine, long string) (opt OptFlag)

func (*StringOpt) Examples Uses

func (s *StringOpt) Examples(examples string) (opt OptFlag)

func (*StringOpt) ExternalTool Uses

func (s *StringOpt) ExternalTool(envKeyName string) (opt OptFlag)

func (*StringOpt) Group Uses

func (s *StringOpt) Group(group string) (opt OptFlag)

func (*StringOpt) Hidden Uses

func (s *StringOpt) Hidden(hidden bool) (opt OptFlag)

func (*StringOpt) Long Uses

func (s *StringOpt) Long(long string) (opt OptFlag)

func (*StringOpt) OwnerCommand Uses

func (s *StringOpt) OwnerCommand() (opt OptCmd)

func (*StringOpt) RootCommand Uses

func (s *StringOpt) RootCommand() (root *RootCommand)

func (*StringOpt) SetOwner Uses

func (s *StringOpt) SetOwner(opt OptCmd)

func (*StringOpt) Short Uses

func (s *StringOpt) Short(short string) (opt OptFlag)

func (*StringOpt) Titles Uses

func (s *StringOpt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*StringOpt) ToggleGroup Uses

func (s *StringOpt) ToggleGroup(group string) (opt OptFlag)

type StringSliceOpt Uses

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

StringSliceOpt for fluent api

func (*StringSliceOpt) Action Uses

func (s *StringSliceOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*StringSliceOpt) Aliases Uses

func (s *StringSliceOpt) Aliases(aliases ...string) (opt OptFlag)

func (*StringSliceOpt) DefaultValue Uses

func (s *StringSliceOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*StringSliceOpt) Deprecated Uses

func (s *StringSliceOpt) Deprecated(deprecation string) (opt OptFlag)

func (*StringSliceOpt) Description Uses

func (s *StringSliceOpt) Description(oneLine, long string) (opt OptFlag)

func (*StringSliceOpt) Examples Uses

func (s *StringSliceOpt) Examples(examples string) (opt OptFlag)

func (*StringSliceOpt) ExternalTool Uses

func (s *StringSliceOpt) ExternalTool(envKeyName string) (opt OptFlag)

func (*StringSliceOpt) Group Uses

func (s *StringSliceOpt) Group(group string) (opt OptFlag)

func (*StringSliceOpt) Hidden Uses

func (s *StringSliceOpt) Hidden(hidden bool) (opt OptFlag)

func (*StringSliceOpt) Long Uses

func (s *StringSliceOpt) Long(long string) (opt OptFlag)

func (*StringSliceOpt) OwnerCommand Uses

func (s *StringSliceOpt) OwnerCommand() (opt OptCmd)

func (*StringSliceOpt) RootCommand Uses

func (s *StringSliceOpt) RootCommand() (root *RootCommand)

func (*StringSliceOpt) SetOwner Uses

func (s *StringSliceOpt) SetOwner(opt OptCmd)

func (*StringSliceOpt) Short Uses

func (s *StringSliceOpt) Short(short string) (opt OptFlag)

func (*StringSliceOpt) Titles Uses

func (s *StringSliceOpt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*StringSliceOpt) ToggleGroup Uses

func (s *StringSliceOpt) ToggleGroup(group string) (opt OptFlag)

type SubCmdOpt Uses

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

SubCmdOpt for fluent api

func (*SubCmdOpt) Action Uses

func (s *SubCmdOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptCmd)

func (*SubCmdOpt) Aliases Uses

func (s *SubCmdOpt) Aliases(aliases ...string) (opt OptCmd)

func (*SubCmdOpt) Bool Uses

func (s *SubCmdOpt) Bool() (opt OptFlag)

func (*SubCmdOpt) Deprecated Uses

func (s *SubCmdOpt) Deprecated(deprecation string) (opt OptCmd)

func (*SubCmdOpt) Description Uses

func (s *SubCmdOpt) Description(oneLine, long string) (opt OptCmd)

func (*SubCmdOpt) Duration Uses

func (s *SubCmdOpt) Duration() (opt OptFlag)

func (*SubCmdOpt) Examples Uses

func (s *SubCmdOpt) Examples(examples string) (opt OptCmd)

func (*SubCmdOpt) Group Uses

func (s *SubCmdOpt) Group(group string) (opt OptCmd)

func (*SubCmdOpt) Hidden Uses

func (s *SubCmdOpt) Hidden(hidden bool) (opt OptCmd)

func (*SubCmdOpt) Int Uses

func (s *SubCmdOpt) Int() (opt OptFlag)

func (*SubCmdOpt) Int64 Uses

func (s *SubCmdOpt) Int64() (opt OptFlag)

func (*SubCmdOpt) IntSlice Uses

func (s *SubCmdOpt) IntSlice() (opt OptFlag)

func (*SubCmdOpt) Long Uses

func (s *SubCmdOpt) Long(long string) (opt OptCmd)

func (*SubCmdOpt) NewFlag Uses

func (s *SubCmdOpt) NewFlag(typ OptFlagType) (opt OptFlag)

func (*SubCmdOpt) NewSubCommand Uses

func (s *SubCmdOpt) NewSubCommand() (opt OptCmd)

func (*SubCmdOpt) OwnerCommand Uses

func (s *SubCmdOpt) OwnerCommand() (opt OptCmd)

func (*SubCmdOpt) PostAction Uses

func (s *SubCmdOpt) PostAction(pre func(cmd *Command, args []string)) (opt OptCmd)

func (*SubCmdOpt) PreAction Uses

func (s *SubCmdOpt) PreAction(pre func(cmd *Command, args []string) (err error)) (opt OptCmd)

func (*SubCmdOpt) RootCommand Uses

func (s *SubCmdOpt) RootCommand() (root *RootCommand)

func (*SubCmdOpt) SetOwner Uses

func (s *SubCmdOpt) SetOwner(opt OptCmd)

func (*SubCmdOpt) Short Uses

func (s *SubCmdOpt) Short(short string) (opt OptCmd)

func (*SubCmdOpt) String Uses

func (s *SubCmdOpt) String() (opt OptFlag)

func (*SubCmdOpt) StringSlice Uses

func (s *SubCmdOpt) StringSlice() (opt OptFlag)

func (*SubCmdOpt) TailPlaceholder Uses

func (s *SubCmdOpt) TailPlaceholder(placeholder string) (opt OptCmd)

func (*SubCmdOpt) Titles Uses

func (s *SubCmdOpt) Titles(short, long string, aliases ...string) (opt OptCmd)

func (*SubCmdOpt) Uint Uses

func (s *SubCmdOpt) Uint() (opt OptFlag)

func (*SubCmdOpt) Uint64 Uses

func (s *SubCmdOpt) Uint64() (opt OptFlag)

type Uint64Opt Uses

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

Uint64Opt for fluent api

func (*Uint64Opt) Action Uses

func (s *Uint64Opt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*Uint64Opt) Aliases Uses

func (s *Uint64Opt) Aliases(aliases ...string) (opt OptFlag)

func (*Uint64Opt) DefaultValue Uses

func (s *Uint64Opt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*Uint64Opt) Deprecated Uses

func (s *Uint64Opt) Deprecated(deprecation string) (opt OptFlag)

func (*Uint64Opt) Description Uses

func (s *Uint64Opt) Description(oneLine, long string) (opt OptFlag)

func (*Uint64Opt) Examples Uses

func (s *Uint64Opt) Examples(examples string) (opt OptFlag)

func (*Uint64Opt) ExternalTool Uses

func (s *Uint64Opt) ExternalTool(envKeyName string) (opt OptFlag)

func (*Uint64Opt) Group Uses

func (s *Uint64Opt) Group(group string) (opt OptFlag)

func (*Uint64Opt) Hidden Uses

func (s *Uint64Opt) Hidden(hidden bool) (opt OptFlag)

func (*Uint64Opt) Long Uses

func (s *Uint64Opt) Long(long string) (opt OptFlag)

func (*Uint64Opt) OwnerCommand Uses

func (s *Uint64Opt) OwnerCommand() (opt OptCmd)

func (*Uint64Opt) RootCommand Uses

func (s *Uint64Opt) RootCommand() (root *RootCommand)

func (*Uint64Opt) SetOwner Uses

func (s *Uint64Opt) SetOwner(opt OptCmd)

func (*Uint64Opt) Short Uses

func (s *Uint64Opt) Short(short string) (opt OptFlag)

func (*Uint64Opt) Titles Uses

func (s *Uint64Opt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*Uint64Opt) ToggleGroup Uses

func (s *Uint64Opt) ToggleGroup(group string) (opt OptFlag)

type UintOpt Uses

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

UintOpt for fluent api

func (*UintOpt) Action Uses

func (s *UintOpt) Action(action func(cmd *Command, args []string) (err error)) (opt OptFlag)

func (*UintOpt) Aliases Uses

func (s *UintOpt) Aliases(aliases ...string) (opt OptFlag)

func (*UintOpt) DefaultValue Uses

func (s *UintOpt) DefaultValue(val interface{}, placeholder string) (opt OptFlag)

func (*UintOpt) Deprecated Uses

func (s *UintOpt) Deprecated(deprecation string) (opt OptFlag)

func (*UintOpt) Description Uses

func (s *UintOpt) Description(oneLine, long string) (opt OptFlag)

func (*UintOpt) Examples Uses

func (s *UintOpt) Examples(examples string) (opt OptFlag)

func (*UintOpt) ExternalTool Uses

func (s *UintOpt) ExternalTool(envKeyName string) (opt OptFlag)

func (*UintOpt) Group Uses

func (s *UintOpt) Group(group string) (opt OptFlag)

func (*UintOpt) Hidden Uses

func (s *UintOpt) Hidden(hidden bool) (opt OptFlag)

func (*UintOpt) Long Uses

func (s *UintOpt) Long(long string) (opt OptFlag)

func (*UintOpt) OwnerCommand Uses

func (s *UintOpt) OwnerCommand() (opt OptCmd)

func (*UintOpt) RootCommand Uses

func (s *UintOpt) RootCommand() (root *RootCommand)

func (*UintOpt) SetOwner Uses

func (s *UintOpt) SetOwner(opt OptCmd)

func (*UintOpt) Short Uses

func (s *UintOpt) Short(short string) (opt OptFlag)

func (*UintOpt) Titles Uses

func (s *UintOpt) Titles(short, long string, aliases ...string) (opt OptFlag)

func (*UintOpt) ToggleGroup Uses

func (s *UintOpt) ToggleGroup(group string) (opt OptFlag)

Directories

PathSynopsis
conf

Package cmdr imports 28 packages (graph). Updated 2019-06-25. Refresh now. Tools for package owners.