test cobra

This commit is contained in:
wangchuxiao
2023-03-08 11:45:54 +08:00
parent 60876e865b
commit e55167d0bf
10 changed files with 223 additions and 144 deletions
+17
View File
@@ -0,0 +1,17 @@
package cmd
import "github.com/spf13/cobra"
type ApiCmd struct {
*RootCmd
}
func NewApiCmd() *ApiCmd {
return &ApiCmd{NewRootCmd()}
}
func (a *ApiCmd) AddApi(f func(port int) error) {
a.Command.RunE = func(cmd *cobra.Command, args []string) error {
return f(a.GetPortFlag())
}
}