root.go 611 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package cmd
  2. import (
  3. "errors"
  4. "fmt"
  5. "github.com/spf13/cobra"
  6. "os"
  7. )
  8. var rootCmd = &cobra.Command{
  9. Use: "flytalk",
  10. Short: "flytalk",
  11. Long: `简洁快速的在线 Web 客服系统`,
  12. Args: args,
  13. Run: func(cmd *cobra.Command, args []string) {
  14. },
  15. }
  16. func args(cmd *cobra.Command, args []string) error {
  17. if len(args) < 1 {
  18. return errors.New("至少需要一个参数!")
  19. }
  20. return nil
  21. }
  22. func Execute() {
  23. if err := rootCmd.Execute(); err != nil {
  24. fmt.Println(err)
  25. os.Exit(1)
  26. }
  27. }
  28. func init() {
  29. rootCmd.AddCommand(versionCmd)
  30. rootCmd.AddCommand(serverCmd)
  31. rootCmd.AddCommand(installCmd)
  32. }