root.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Copyright © 2022 NAME HERE <EMAIL ADDRESS>
  3. */
  4. package cmd
  5. import (
  6. "os"
  7. "github.com/spf13/cobra"
  8. )
  9. // rootCmd represents the base command when called without any subcommands
  10. var rootCmd = &cobra.Command{
  11. Use: "cobra",
  12. Short: "A brief description of your application",
  13. Long: `A longer description that spans multiple lines and likely contains
  14. examples and usage of using your application. For example:
  15. Cobra is a CLI library for Go that empowers applications.
  16. This application is a tool to generate the needed files
  17. to quickly create a Cobra application.`,
  18. // Uncomment the following line if your bare application
  19. // has an action associated with it:
  20. // Run: func(cmd *cobra.Command, args []string) { },
  21. }
  22. // Execute adds all child commands to the root command and sets flags appropriately.
  23. // This is called by main.main(). It only needs to happen once to the rootCmd.
  24. func Execute() {
  25. err := rootCmd.Execute()
  26. if err != nil {
  27. os.Exit(1)
  28. }
  29. }
  30. func init() {
  31. // Here you will define your flags and configuration settings.
  32. // Cobra supports persistent flags, which, if defined here,
  33. // will be global for your application.
  34. // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra2.yaml)")
  35. // Cobra also supports local flags, which will only run
  36. // when this action is called directly.
  37. rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
  38. }