Skip to content

Commit

Permalink
fix: handle flag bind error, make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhop committed May 20, 2024
1 parent 800c167 commit 543e463
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package cmd

import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package cmd

import (
"fmt"
"log"
"os"
"path/filepath"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 543e463

Please sign in to comment.