| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package cmd
- import (
- "errors"
- "fmt"
- "os"
- "github.com/spf13/cobra"
- "device-manage/cmd/api"
- "device-manage/cmd/config"
- "device-manage/cmd/migrate"
- "device-manage/cmd/version"
- "device-manage/common/global"
- "device-manage/tools"
- )
- var rootCmd = &cobra.Command{
- Use: "device-manage",
- Short: "device-manage",
- SilenceUsage: true,
- Long: `device-manage`,
- Args: func(cmd *cobra.Command, args []string) error {
- if len(args) < 1 {
- tip()
- return errors.New(tools.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 := `欢迎使用 ` + tools.Green(`device-manage `+global.Version) + ` 可以使用 ` + tools.Red(`-h`) + ` 查看命令`
- usageStr1 := `也可以参考 http://doc.zhangwj.com/device-manage-site/guide/ksks.html 里边的【启动】章节`
- fmt.Printf("%s\n", usageStr)
- fmt.Printf("%s\n", usageStr1)
- }
- func init() {
- rootCmd.AddCommand(api.StartCmd)
- rootCmd.AddCommand(migrate.StartCmd)
- rootCmd.AddCommand(version.StartCmd)
- rootCmd.AddCommand(config.StartCmd)
- }
- //Execute : apply commands
- func Execute() {
- if err := rootCmd.Execute(); err != nil {
- os.Exit(-1)
- }
- }
|