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