package cmd import ( "Medical_OAuth/common/global" "errors" "fmt" "os" "github.com/spf13/cobra" "Medical_OAuth/cmd/api" "Medical_OAuth/cmd/config" "Medical_OAuth/cmd/migrate" "gogs.baozhida.cn/zoie/OAuth-core/pkg" ) var rootCmd = &cobra.Command{ Use: "Medical_OAuth", Short: "Medical_OAuth", SilenceUsage: true, Long: `OAuth`, Args: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { tip() return errors.New(pkg.Red("requires at least one arg")) } return nil }, PersistentPreRunE: func(*cobra.Command, []string) error { return nil }, Run: func(cmd *cobra.Command, args []string) { tip() }, } func tip() { usageStr := `欢迎使用 ` + pkg.Green(`OAuth `+global.Version) + ` 可以使用 ` + pkg.Red(`-h`) + ` 查看命令` fmt.Printf("%s\n", usageStr) } func init() { rootCmd.AddCommand(api.StartCmd) rootCmd.AddCommand(config.StartCmd) rootCmd.AddCommand(migrate.StartCmd) } // Execute : apply commands func Execute() { if err := rootCmd.Execute(); err != nil { os.Exit(-1) } }