You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1012 B
43 lines
1012 B
/*
|
|
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
|
|
|
*/
|
|
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/.diary.toml)")
|
|
viper.BindPFlag("config", rootCmd.Flags().Lookup("config"))
|
|
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
}
|