/* Copyright © 2022 NAME HERE */ package cmd import ( "os" "github.com/spf13/cobra" "github.com/spf13/viper" ) // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ Use: "diary", Short: "A software engineer's log", Long: `Use diary to keep track of your day. Example: $ diary add "Security meeting minutes" 33 $ diary add note 33 # opens in your $EDITOR $ diary list today # Show all the entries added today `, } // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { err := rootCmd.Execute() if err != nil { os.Exit(1) } } func init() { cobra.OnInitialize(InitApp) rootCmd.PersistentFlags().String("config", "", "config file (default is $HOME/config/diary/diary.toml)") viper.BindPFlag("config", rootCmd.Flags().Lookup("config")) rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") }