package cmd import ( "fmt" "log/slog" "os" "github.com/spf13/cobra" ) var cfgFile string var verbose int // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "kontor-cli", Short: "A brief description of your application", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your application. For example: Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, // Uncomment the following line if your bare application // has an action associated with it: Run: func(cmd *cobra.Command, args []string) { cmd.Help() slog.Info("Verbosity level", "level", verbose) }, } func Execute() { if err := rootCmd.Execute(); err != nil { fmt.Fprintf(os.Stderr, "Oops. An error while executing Zero '%s'\n", err) os.Exit(1) } } func init() { rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.config/kli.yaml)") rootCmd.PersistentFlags().CountVarP(&verbose, "verbose", "v", "increase verbosity (-v, -vv, -vvv)") }