app

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatUseName

func FormatUseName(basename string) string

FormatUseName 用于转换应用的文件名称

Types

type App

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

func NewApp

func NewApp(use string, short string, opts ...Option) *App

NewApp create a new app.

func (App) Command

func (a App) Command() *cobra.Command

func (*App) Run

func (a *App) Run()

type CliOptions

type CliOptions interface {
	Flags() (fss flag.NamedFlagSets)
	Validate() []error
}

type Command

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

func NewCommand

func NewCommand(use, short string, opts ...CommandOption) *Command

NewCommand 用于生成 Command

func (Command) AddCommands

func (c Command) AddCommands(cmd ...*Command)

AddCommands AddCommand 用于追加 command

type CommandOption

type CommandOption func(*Command)

func WithCommandOptions

func WithCommandOptions(opt CliOptions) CommandOption

func WithCommandRunFunc

func WithCommandRunFunc(rcf RunCommandFunc) CommandOption

type CompletableOptions

type CompletableOptions interface {
	Complete() error
}

CompletableOptions abstracts options, which can be completed.

type ConfigurableOptions

type ConfigurableOptions interface {
	// ApplyFlags parsing parameters from the command line or configuration file
	// to the options instance.
	ApplyFlags() []error
}

ConfigurableOptions abstracts configuration options for reading parameters from a configuration file.

type Option

type Option func(*App)

func WithDefaultValidArgs

func WithDefaultValidArgs() Option

func WithLong

func WithLong(desc string) Option

func WithOptions

func WithOptions(opt CliOptions) Option

func WithRunFunc

func WithRunFunc(runFunc RunFunc) Option

func WithSilence

func WithSilence(silence bool) Option

func WithUseConfig

func WithUseConfig(useConfig bool) Option

func WithValidArgs

func WithValidArgs(args cobra.PositionalArgs) Option

func WithVersion

func WithVersion(version bool) Option

type PrintableOptions

type PrintableOptions interface {
	String() string
}

PrintableOptions abstracts options, which can be printed.

type RunCommandFunc

type RunCommandFunc func(args []string) error

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