init project

This commit is contained in:
yanghao05
2023-01-28 11:09:11 +08:00
parent 11a561bdd7
commit 114c003b2b
38 changed files with 2011 additions and 0 deletions

38
cmd/root.go Normal file
View File

@@ -0,0 +1,38 @@
package cmd
import (
_ "app/providers"
"app/container"
"app/services/http"
"app/utils"
"fmt"
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "app",
Short: "app",
Long: `the app long description`,
Version: fmt.Sprintf("\nVersion: %s\nGitHash: %s\nBuildAt: %s\n", utils.Version, utils.GitHash, utils.BuildAt),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// fmt.Println("using config file: ", utils.ShareConfigFile)
},
RunE: func(cmd *cobra.Command, args []string) error {
return container.Container.Invoke(http.Serve)
},
}
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
rootCmd.PersistentFlags().StringVarP(&utils.ShareConfigFile, "config", "c", "config.toml", "config file")
}