package cmd import ( "fmt" "os" "github.com/spf13/cobra" "github.com/spf13/viper" ) const VERSION string = "0.1" var ( version bool dry_run bool rootCmd = &cobra.Command{ Use: "gitw", Short: "Git issue and milestone integration for taskwarrior", Long: `Gitwarrior is a CLI tool to extend the taskwarrior tasks to synch issues and milestones. Gitwarrior requires requires the following uda's to be defined: last_gitw_update(date), git_number(number), git_type(string), git_comment_ids(string).`, } ) func Execute() error { return rootCmd.Execute() } func init() { cobra.OnInitialize(initConfig) // version flag rootCmd.Flags().BoolVarP(&version, "version", "v", false, "Print version of gitwarrior") rootCmd.Version = VERSION } func initConfig() { viper.SetConfigName("config") viper.SetConfigType("yaml") viper.AddConfigPath("$HOME/.config/gitw") viper.AutomaticEnv() if err := viper.ReadInConfig(); err != nil { fmt.Fprintf(os.Stderr, "Failed to read configuration file: %s\n", err) os.Exit(-1) } }