app

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBaseName

func FormatBaseName(basename string) string

FormatBaseName 格式化基础名称

Types

type App

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

App 应用

func NewApp

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

NewApp 创建应用

func (*App) Run

func (a *App) Run()

Run 运行应用程序

type CliOptions

type CliOptions interface {
	// Flags 返回一个 NamedFlagSets 对象,包含所有命令行参数
	Flags() (fss cliflag.NamedFlagSets)
	// Validate 验证命令行参数
	Validate() []error
}

CliOptions 命令行选项

type Command

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

Command 命令

func NewCommand

func NewCommand(usage string, desc string, opts ...CommandOption) *Command

NewCommand 创建命令

type CommandOption

type CommandOption func(*Command)

CommandOption 命令选项

type CompleteableOptions

type CompleteableOptions interface {
	Complete() error
}

CompleteableOptions 抽象选项,可以被完成

type Option

type Option func(*App)

Option 应用选项

func WithDefaultValidArgs

func WithDefaultValidArgs() Option

WithDefaultValidArgs 设置默认的 args

func WithDescription

func WithDescription(description string) Option

WithDescription 设置应用程序的描述

func WithOptions

func WithOptions(opt CliOptions) Option

WithOptions 打开应用程序的函数,从命令行或配置文件中读取参数

func WithRunFunc

func WithRunFunc(run RunFunc) Option

WithRunFunc 设置应用程序的启动回调函数选项

func WithValidArgs

func WithValidArgs(args cobra.PositionalArgs) Option

WithValidArgs 设置 args

type PrintableOptions

type PrintableOptions interface {
	String() string
}

PrintableOptions 抽象选项,可以被打印

type RunCommandFunc

type RunCommandFunc func(args []string) error

RunCommandFunc 定义应用程序的命令启动回调函数

type RunFunc

type RunFunc func(basename string) error

RunFunc 定义应用程序的启动回调函数

Jump to

Keyboard shortcuts

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