Integrate cobra into the framework part1

This commit is contained in:
Muyao CHEN
2024-09-30 19:38:16 +02:00
parent fc4f94e967
commit 9da3012789
13 changed files with 159 additions and 42 deletions

30
app/console/kernel.go Normal file
View File

@ -0,0 +1,30 @@
package console
import (
"git.vinchent.xyz/vinchent/go-web/framework"
"git.vinchent.xyz/vinchent/go-web/framework/commands"
"github.com/spf13/cobra"
)
func RunCommand(container framework.Container) error {
rootCmd := &cobra.Command{
Use: "goweb",
Short: "goweb command",
Long: "the command line tool for goweb framework.",
RunE: func(cmd *cobra.Command, args []string) error {
cmd.InitDefaultHelpFlag()
return cmd.Help()
},
CompletionOptions: cobra.CompletionOptions{DisableDefaultCmd: true},
}
rootCmd.SetContainer(container)
commands.AddKernelCommands(rootCmd)
AddAppCommand(rootCmd)
return rootCmd.Execute()
}
func AddAppCommand(rootCmd *cobra.Command) {
// rootCmd.AddCommand(demo.InitFoo())
}