cobra.go 551 B

123456789101112131415161718192021222324252627282930313233343536
  1. package cmd
  2. import (
  3. "os"
  4. )
  5. import (
  6. "github.com/spf13/cobra"
  7. )
  8. import (
  9. "resource-server/cmd/httpserver"
  10. "resource-server/cmd/version"
  11. )
  12. var rootCmd = &cobra.Command{
  13. Use: "resource-server",
  14. Short: "rs",
  15. SilenceUsage: true,
  16. Long: `rs server`,
  17. Run: func(cmd *cobra.Command, args []string) {
  18. cmd.Help()
  19. },
  20. }
  21. func init() {
  22. rootCmd.AddCommand(httpserver.StartCmd)
  23. rootCmd.AddCommand(version.StartCmd)
  24. }
  25. // Execute : apply commands
  26. func Execute() {
  27. if err := rootCmd.Execute(); err != nil {
  28. os.Exit(-1)
  29. }
  30. }