diff --git a/cmd/edit.go b/cmd/edit.go index 9ed386c..192f0cd 100644 --- a/cmd/edit.go +++ b/cmd/edit.go @@ -22,6 +22,7 @@ package cmd import ( "fmt" + "log" "os" "os/exec" "path/filepath" @@ -63,7 +64,9 @@ func init() { editCmd.Flags().StringVarP(&editor, "editor", "e", "", "location of template directory (default is $HOME/clip)") // use viper to bind config to CLI flags - viper.BindPFlag("editor", editCmd.Flags().Lookup("editor")) + if err := viper.BindPFlag("editor", editCmd.Flags().Lookup("editor")); err != nil { + log.Fatal("Failed to bind `editor` flag") + } } func openClipTemplateInEditor(filename string) error { diff --git a/cmd/root.go b/cmd/root.go index 450ae6f..640bfb9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -22,6 +22,7 @@ package cmd import ( "fmt" + "log" "os" "path/filepath" @@ -84,7 +85,9 @@ func init() { rootCmd.Flags().BoolVarP(&showBuild, "version", "v", false, "clip version and build info") // use viper to bind config to CLI flags - viper.BindPFlag("templatedir", rootCmd.PersistentFlags().Lookup("templatedir")) + if err := viper.BindPFlag("templatedir", rootCmd.PersistentFlags().Lookup("templatedir")); err != nil { + log.Fatal("Failed to bind `templatedir` flag") + } } // initClip will set config defaults, read in config file, and initialize clip template directory if it doesn't exist yet