app

package
v0.0.0-...-455e706 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBaseName

func FormatBaseName(basename string) string

二进制名

Types

type App

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

应用框架构建

func NewApp

func NewApp(name string, basename string, opts ...Option) *App

func (*App) Run

func (a *App) Run()

运行 cmd中的函数

type CliOptions

type CliOptions interface {
	// AddFlags adds flags to the specified FlagSet object.
	// AddFlags(fs *pflag.FlagSet)
	Flags() (fss cliflag.NamedFlagSets) //返回多个 pflag.FlagSet 就是记录
	Validate() []error                  // 验证基本参数是否正确
}

命令行接口

type Command

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

Command 为 root 的子命令

type CompleteableOptions

type CompleteableOptions interface {
	Complete() error
}

CompleteableOptions 抽象了可以完成的选项。

type Option

type Option func(app *App)

选项模式给动态给 APP 赋值

func WithDefaultValidArgs

func WithDefaultValidArgs() Option

构建 验证函数 并且若 func(cmd *cobra.Command, args []string) len(args) >0 则 return 非必须

func WithDescription

func WithDescription(description string) Option

构建详情描述选项

func WithOptions

func WithOptions(opt CliOptions) Option

构建options选项

func WithRunFunc

func WithRunFunc(run RunFunc) Option

构建运行函数选项

type PrintableOptions

type PrintableOptions interface {
	String() string
}

PrintableOptions 可打印的摘要选项。

type RunCommandFunc

type RunCommandFunc func(args []string) error

运行 函数 cobra.Command 的 Run 参数

type RunFunc

type RunFunc func(basename string) error

运行函数

Jump to

Keyboard shortcuts

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