From bedf3341fb667c2c9401b492b483f3ee240165c1 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 2 Nov 2024 20:05:05 -0400 Subject: [PATCH] fix: clean up commands --- cmd/fix.go | 5 +++++ cmd/root.go | 4 +--- cmd/version.go | 9 +++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/fix.go b/cmd/fix.go index 87b536b..254f13b 100644 --- a/cmd/fix.go +++ b/cmd/fix.go @@ -43,6 +43,11 @@ func Diagnose(cmd *cobra.Command, args []string) { u.LogErrorAndExit(err) } + if len(config) == 0 { + fmt.Fprintf(os.Stderr, "Error: configuration file is empty\n") + os.Exit(1) + } + // Generate a formatted prompt for the recommendations function formattedPrompt := fmt.Sprintf(`Error detected in configuration file '%s': diff --git a/cmd/root.go b/cmd/root.go index 9f45bbe..16b60da 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -2,7 +2,6 @@ package cmd import ( "fmt" - "os" "github.com/RoseSecurity/kuzco/internal" tuiUtils "github.com/RoseSecurity/kuzco/internal/tui/utils" @@ -48,8 +47,7 @@ func runAnalyzer(cmd *cobra.Command, args []string) { // Validate that the specified model exists in Ollama if err := internal.ValidateModel(model, addr); err != nil { - fmt.Fprintf(os.Stderr, "Model validation error: %v\n", err) - os.Exit(1) + u.LogErrorAndExit(err) } cmd.Help() } diff --git a/cmd/version.go b/cmd/version.go index 9ed89be..c3d6822 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -9,6 +9,7 @@ import ( "github.com/fatih/color" "github.com/spf13/cobra" + "golang.org/x/mod/semver" ) // Placeholder for builds @@ -29,8 +30,8 @@ var versionCmd = &cobra.Command{ if err == nil && latestReleaseTag != "" { latestRelease := strings.TrimPrefix(latestReleaseTag, "v") currentRelease := strings.TrimPrefix(Version, "v") - if latestRelease > currentRelease { - updateTerramaid(latestRelease) + if semver.Compare(latestRelease, currentRelease) > 0 { + updateKuzco(latestRelease) } } }, @@ -58,8 +59,8 @@ func latestRelease() (string, error) { } // Display out of date warning -func updateTerramaid(latestVersion string) { +func updateKuzco(latestVersion string) { c1 := color.New(color.FgCyan) - c1.Println(fmt.Sprintf("\nYour version of Terramaid is out of date. The latest version is %s\n\n", latestVersion)) + c1.Println(fmt.Sprintf("\nYour version of Kuzco is out of date. The latest version is %s\n\n", latestVersion)) }