test cobra

This commit is contained in:
wangchuxiao 2023-03-07 18:32:20 +08:00
parent 6eb13df2e2
commit 6bb8160a99
2 changed files with 2 additions and 2 deletions

View File

@ -29,7 +29,7 @@ var startCmd = &cobra.Command{
func main() {
startCmd.Flags().IntP(constant.FlagPort, "p", 0, "Port to listen on")
startCmd.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder")
rootCmd := cmd.NewRootCmd()
rootCmd := cmd.NewRootCmd(nil)
rootCmd.Command.AddCommand(startCmd)
if err := startCmd.Execute(); err != nil {
fmt.Println(err)

View File

@ -10,7 +10,7 @@ type RootCmd struct {
Command cobra.Command
}
func NewRootCmd() RootCmd {
func NewRootCmd(f func() error) RootCmd {
c := cobra.Command{
Use: "start",
Short: "Start the server",