Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ConfigFileFlag = Flag{ Name: "config", ConfigName: "config", Shorthand: "c", Value: "config.yaml", Usage: "指定config配置文件的路径", Persistent: true, } ShowVersionFlag = Flag{ Name: "version", ConfigName: "version", Shorthand: "v", Value: false, Usage: "展示版本信息", Persistent: true, } QuietFlag = Flag{ Name: "quiet", ConfigName: "quiet", Shorthand: "q", Value: false, Usage: "关闭进度条和日志输出", Persistent: true, } DebugFlag = Flag{ Name: "debug", ConfigName: "debug", Shorthand: "d", Value: false, Usage: "指定 debug 模式", Persistent: true, } TimeoutFlag = Flag{ Name: "timeout", ConfigName: "timeout", Value: time.Second * 300, Usage: "指定超时时间", Persistent: true, } CacheDirFlag = Flag{ Name: "cache-dir", ConfigName: "cache.dir", Value: utils.DefaultCacheDir(), Usage: "指定缓存目录", Persistent: true, } )
Functions ¶
This section is empty.
Types ¶
type Flag ¶
type Flag struct { // Name is for CLI flag and environment variable. // If this field is empty, it will be available only in config file. Name string // ConfigName is a key in config file. It is also used as a key of viper. ConfigName string // Shorthand is a shorthand letter. Shorthand string // Value is the default value. It must be filled to determine the flag type. Value interface{} // Usage explains how to use the flag. Usage string // Persistent represents if the flag is persistent Persistent bool // Deprecated represents if the flag is deprecated Deprecated bool }
Flag 标志
type GlobalFlagGroup ¶
type GlobalFlagGroup struct { ConfigFile *Flag ShowVersion *Flag // spf13/cobra can't override the logic of version printing like VersionPrinter in urfave/cli. -v needs to be defined ourselves. Quiet *Flag Debug *Flag Timeout *Flag CacheDir *Flag }
GlobalFlagGroup composes global flags
func NewGlobalFlagGroup ¶
func NewGlobalFlagGroup() *GlobalFlagGroup
func (*GlobalFlagGroup) AddFlags ¶
func (f *GlobalFlagGroup) AddFlags(cmd *cobra.Command)
func (*GlobalFlagGroup) ToOptions ¶
func (f *GlobalFlagGroup) ToOptions() GlobalOptions
Click to show internal directories.
Click to hide internal directories.