命令
简介
基础示例
创建命令
Command interface {
// 返回一个新的 cobra command
CobraCmd() *cobra.Command
// 业务主入口
Run(root BaseCommand, cmd *cobra.Command, args []string)
}import (
"fmt"
"github.com/firmeve/firmeve"
"github.com/firmeve/firmeve/kernel/contract"
"github.com/spf13/cobra"
)
type TestCommand struct {
}
func (t TestCommand) CobraCmd() *cobra.Command {
cmd := &cobra.Command{}
cmd.Use = "testing"
cmd.Short = "Testing a cmd"
return cmd
}
func (t TestCommand) Run(root contract.BaseCommand, cmd *cobra.Command, args []string) {
fmt.Println("run")
}命令注册
内置命令
更多用法
Last updated