Skip to content

Commit

Permalink
fix: streamline error handling and update
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradumnasaraf committed Feb 9, 2025
1 parent 7b7c31d commit 7569464
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
4 changes: 1 addition & 3 deletions cmd/changeModelCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ func setModelConfig() {
}

err := survey.AskOne(prompt, &selected)
if err != nil {
fmt.Println("Error:", err)
}
CheckNilError(err)

switch selected {
case "Gemini 2.0 Flash":
Expand Down
9 changes: 0 additions & 9 deletions cmd/checkNilError.go

This file was deleted.

6 changes: 6 additions & 0 deletions cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ func getHomeDir() string {
}
return homeDir
}

func CheckNilError(err error) {
if err != nil {
log.Fatal(err)
}
}
5 changes: 1 addition & 4 deletions cmd/updateCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ func update() {
cmd := exec.Command("go", "install", "github.com/Pradumnasaraf/gencli@latest")
_, err := cmd.Output()

if err != nil {
fmt.Println("Error executing command:", err)
return
}
CheckNilError(err)

fmt.Printf("CLI updated successfully to the latest version (If any).")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/versionCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
)

const CliVersion = "v1.6.0"
const CliVersion = "v1.6.2"

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Expand Down

0 comments on commit 7569464

Please sign in to comment.