Integrate cobra into the framework part1
This commit is contained in:
		
							
								
								
									
										30
									
								
								app/console/kernel.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								app/console/kernel.go
									
									
									
									
									
										Normal 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())
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user