root.go 916 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package host
  2. import (
  3. "os"
  4. "github.com/spf13/cobra"
  5. )
  6. // rootCmd represents the base command when called without any subcommands
  7. var rootCmd = &cobra.Command{
  8. Use: "host",
  9. Short: "Manage hosts",
  10. Long: `Manage hosts`,
  11. }
  12. // GetRoot returns the root subcommand
  13. func GetRoot() *cobra.Command {
  14. return rootCmd
  15. }
  16. // Execute adds all child commands to the root command and sets flags appropriately.
  17. // This is called by main.main(). It only needs to happen once to the rootCmd.
  18. func Execute() {
  19. err := rootCmd.Execute()
  20. if err != nil {
  21. os.Exit(1)
  22. }
  23. }
  24. func init() {
  25. // Here you will define your flags and configuration settings.
  26. // Cobra supports persistent flags, which, if defined here,
  27. // will be global for your application.
  28. // Cobra also supports local flags, which will only run
  29. // when this action is called directly.
  30. rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
  31. }