cmdbase

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseCommand

type BaseCommand struct {
	CobraCmd *cobra.Command
}

BaseCommand 基础命令结构体,提供通用实现

func (*BaseCommand) GetCobraCmd

func (b *BaseCommand) GetCobraCmd() *cobra.Command

GetCobraCmd 获取cobra命令

type Command

type Command interface {
	// Init 初始化命令,设置标志等
	Init()
	// GetCobraCmd 获取cobra命令
	GetCobraCmd() *cobra.Command
}

Command 命令接口,所有命令都需要实现此接口

type CommandRegistry

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

CommandRegistry 命令注册表,保存所有注册的命令

func NewCommandRegistry

func NewCommandRegistry(rootCmd *cobra.Command) *CommandRegistry

NewCommandRegistry 创建一个命令注册表

func (*CommandRegistry) Execute

func (r *CommandRegistry) Execute() error

Execute 执行根命令

func (*CommandRegistry) Register

func (r *CommandRegistry) Register(cmd Command)

Register 注册命令

func (*CommandRegistry) RegisterCommands

func (r *CommandRegistry) RegisterCommands()

RegisterCommands 注册所有命令

Jump to

Keyboard shortcuts

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