1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- package cmd
- import (
- "errors"
- "fmt"
- "os"
- "git.cestong.com.cn/cecf/hx-admin-server/cmd/app"
- "git.cestong.com.cn/cecf/hx-admin-server/cmd/userapi"
- "git.cestong.com.cn/cecf/hx-admin-server/common/global"
- "github.com/go-admin-team/go-admin-core/sdk/pkg"
- "github.com/spf13/cobra"
- "git.cestong.com.cn/cecf/hx-admin-server/cmd/api"
- "git.cestong.com.cn/cecf/hx-admin-server/cmd/config"
- "git.cestong.com.cn/cecf/hx-admin-server/cmd/migrate"
- "git.cestong.com.cn/cecf/hx-admin-server/cmd/version"
- )
- var rootCmd = &cobra.Command{
- Use: "cecf-hx",
- Short: "cecf-hx",
- SilenceUsage: true,
- Long: `cecf-hx`,
- 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(`cecf-hx `+global.Version) + ` 可以使用 ` + pkg.Red(`-h`) + ` 查看命令`
- fmt.Printf("%s\n", usageStr)
- }
- func init() {
- rootCmd.AddCommand(api.StartCmd)
- rootCmd.AddCommand(migrate.StartCmd)
- rootCmd.AddCommand(version.StartCmd)
- rootCmd.AddCommand(config.StartCmd)
- rootCmd.AddCommand(app.StartCmd)
- rootCmd.AddCommand(userapi.StartCmd)
- }
- //Execute : apply commands
- func Execute() {
- if err := rootCmd.Execute(); err != nil {
- os.Exit(-1)
- }
- }
|