2020-07-13 20:33:20 +08:00
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"ferry/cmd/api"
|
|
|
|
|
"ferry/cmd/migrate"
|
2020-08-15 23:34:37 +08:00
|
|
|
|
"ferry/pkg/logger"
|
2020-07-13 20:33:20 +08:00
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var rootCmd = &cobra.Command{
|
|
|
|
|
Use: "ferry",
|
|
|
|
|
Short: "-v",
|
|
|
|
|
SilenceUsage: true,
|
|
|
|
|
DisableAutoGenTag: true,
|
|
|
|
|
Long: `ferry`,
|
|
|
|
|
Args: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
if len(args) < 1 {
|
|
|
|
|
return errors.New("requires at least one arg")
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
},
|
|
|
|
|
PersistentPreRunE: func(*cobra.Command, []string) error { return nil },
|
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2020-09-01 18:08:59 +08:00
|
|
|
|
usageStr := `欢迎使用 ferry,可以使用 -h 查看命令`
|
2020-08-15 23:34:37 +08:00
|
|
|
|
logger.Infof("%s\n", usageStr)
|
2020-07-13 20:33:20 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
rootCmd.AddCommand(api.StartCmd)
|
|
|
|
|
rootCmd.AddCommand(migrate.StartCmd)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Execute : apply commands
|
|
|
|
|
func Execute() {
|
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
|
|
|
os.Exit(-1)
|
|
|
|
|
}
|
|
|
|
|
}
|