From 7f36f0336071ed012faa4716ca387062305f76bd Mon Sep 17 00:00:00 2001 From: jokestax Date: Wed, 3 Jul 2024 01:16:18 +0530 Subject: [PATCH] added bubbletea quit method instead of os exit --- cmd/k3d/create.go | 3 ++- cmd/logs.go | 4 ++-- cmd/root.go | 3 +-- internal/k3d/menu.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/k3d/create.go b/cmd/k3d/create.go index 544f12e64..76974a9b6 100644 --- a/cmd/k3d/create.go +++ b/cmd/k3d/create.go @@ -31,6 +31,7 @@ import ( "github.com/kubefirst/kubefirst/internal/catalog" "github.com/kubefirst/kubefirst/internal/gitShim" "github.com/kubefirst/kubefirst/internal/segment" + "github.com/kubefirst/kubefirst/internal/progress" "github.com/kubefirst/kubefirst/internal/utilities" "github.com/kubefirst/metrics-client/pkg/telemetry" "github.com/kubefirst/runtime/configs" @@ -1407,7 +1408,7 @@ func runK3d(cmd *cobra.Command, args []string) error { reports.LocalHandoffScreenV2(viper.GetString("components.argocd.password"), clusterNameFlag, gitDestDescriptor, cGitOwner, config, ciFlag) if ciFlag { - os.Exit(0) + progress.Progress.Quit() } } diff --git a/cmd/logs.go b/cmd/logs.go index 34eb311e7..117738347 100755 --- a/cmd/logs.go +++ b/cmd/logs.go @@ -8,9 +8,9 @@ package cmd import ( "fmt" - "os" "github.com/kubefirst/kubefirst/internal/provisionLogs" + "github.com/kubefirst/kubefirst/internal/progress" "github.com/nxadm/tail" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -28,7 +28,7 @@ var logsCmd = &cobra.Command{ t, err := tail.TailFile(viper.GetString("k1-paths.log-file"), tail.Config{Follow: true, ReOpen: true}) if err != nil { fmt.Printf("Error tailing log file: %v\n", err) - os.Exit(1) + progress.Progress.Quit() } for line := range t.Lines { diff --git a/cmd/root.go b/cmd/root.go index b85fbad8d..29ce8545b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -8,7 +8,6 @@ package cmd import ( "fmt" - "os" "github.com/kubefirst/kubefirst/cmd/aws" "github.com/kubefirst/kubefirst/cmd/civo" @@ -51,7 +50,7 @@ func Execute() { err := rootCmd.Execute() if err != nil { fmt.Printf("\nIf a detailed error message was available, please make the necessary corrections before retrying.\nYou can re-run the last command to try the operation again.\n\n") - os.Exit(1) + progress.Progress.Quit() } } diff --git a/internal/k3d/menu.go b/internal/k3d/menu.go index 2080c2c52..e51e4c9d5 100644 --- a/internal/k3d/menu.go +++ b/internal/k3d/menu.go @@ -11,7 +11,7 @@ import ( "io" "os" "strings" - + "github.com/kubefirst/kubefirst/internal/progress" "github.com/charmbracelet/bubbles/list" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" @@ -125,7 +125,7 @@ func MongoDestinationChooser(inCluster bool) string { model, err := tea.NewProgram(m).Run() if err != nil { fmt.Println("Error running program:", err) - os.Exit(1) + progress.Progress.Quit() } var result string