diff --git a/cmd/k3d/mkcert.go b/cmd/k3d/mkcert.go index 6da8dfc3d..80a829af5 100644 --- a/cmd/k3d/mkcert.go +++ b/cmd/k3d/mkcert.go @@ -9,6 +9,7 @@ package k3d import ( "fmt" + "github.com/kubefirst/kubefirst/internal/progress" "github.com/kubefirst/runtime/pkg/helpers" "github.com/kubefirst/runtime/pkg/k3d" "github.com/kubefirst/runtime/pkg/k8s" @@ -51,6 +52,7 @@ func mkCert(cmd *cobra.Command, args []string) error { } log.Infof("Certificate generated. You can use it with an app by setting `tls.secretName: %s-tls` on a Traefik IngressRoute.", appNameFlag) + progress.Progress.Quit() return nil } diff --git a/cmd/k3d/root-credentials.go b/cmd/k3d/root-credentials.go index 174e6dcff..afec3409e 100644 --- a/cmd/k3d/root-credentials.go +++ b/cmd/k3d/root-credentials.go @@ -10,6 +10,7 @@ import ( "fmt" "github.com/kubefirst/kubefirst-api/pkg/credentials" + "github.com/kubefirst/kubefirst/internal/progress" "github.com/kubefirst/runtime/pkg/k3d" "github.com/kubefirst/runtime/pkg/k8s" "github.com/spf13/cobra" @@ -63,5 +64,7 @@ func getK3dRootCredentials(cmd *cobra.Command, args []string) error { return err } + progress.Progress.Quit() + return nil } diff --git a/cmd/k3d/vault.go b/cmd/k3d/vault.go index 1575f6ac4..e88979cf4 100644 --- a/cmd/k3d/vault.go +++ b/cmd/k3d/vault.go @@ -14,6 +14,7 @@ import ( "time" vaultapi "github.com/hashicorp/vault/api" + "github.com/kubefirst/kubefirst/internal/progress" "github.com/kubefirst/runtime/pkg/helpers" "github.com/kubefirst/runtime/pkg/k3d" "github.com/kubefirst/runtime/pkg/k8s" @@ -112,6 +113,8 @@ func unsealVault(cmd *cobra.Command, args []string) error { return fmt.Errorf("vault is already unsealed") } + progress.Progress.Quit() + return nil } diff --git a/cmd/letsencrypt.go b/cmd/letsencrypt.go index 81be1e7b5..d1d06339b 100644 --- a/cmd/letsencrypt.go +++ b/cmd/letsencrypt.go @@ -10,6 +10,7 @@ import ( "fmt" "github.com/kubefirst/kubefirst-api/pkg/certificates" + "github.com/kubefirst/kubefirst/internal/progress" "github.com/spf13/cobra" ) @@ -41,6 +42,7 @@ func status() *cobra.Command { if err != nil { fmt.Println(err) } + progress.Progress.Quit() }, } diff --git a/cmd/reset.go b/cmd/reset.go index 79e24dd3e..7ecf09477 100755 --- a/cmd/reset.go +++ b/cmd/reset.go @@ -12,6 +12,7 @@ import ( "strconv" "time" + "github.com/kubefirst/kubefirst/internal/progress" "github.com/kubefirst/runtime/pkg" "github.com/kubefirst/runtime/pkg/helpers" "github.com/kubefirst/runtime/pkg/progressPrinter" @@ -131,6 +132,7 @@ func runReset() error { progressPrinter.IncrementTracker("removing-platform-content", 1) time.Sleep(time.Second * 2) + progress.Progress.Quit() return nil } diff --git a/internal/progress/message.go b/internal/progress/message.go index 248c1a14a..3bcbee3e1 100644 --- a/internal/progress/message.go +++ b/internal/progress/message.go @@ -53,13 +53,19 @@ func createErrorLog(message string) errorMsg { func DisplayLogHints(estimatedTime int) { logFile := viper.GetString("k1-paths.log-file") cloudProvider := viper.GetString("kubefirst.cloud-provider") + + documentationLink := "https://docs.kubefirst.io/" + if cloudProvider != "" { + documentationLink = documentationLink + cloudProvider + `/quick-start/install/cli` + } + header := ` ## # Welcome to Kubefirst ### :bulb: To view verbose logs run below command in new terminal: ` + fmt.Sprintf("##### **tail -f -n +1 %s**", logFile) + ` -### :blue_book: Documentation: https://docs.kubefirst.io/` + cloudProvider + `/quick-start/install/cli +### :blue_book: Documentation: ` + documentationLink + ` ### :alarm_clock: Estimated time:` + fmt.Sprintf("`%s minutes` \n\n", strconv.Itoa(estimatedTime)) diff --git a/internal/progress/progress.go b/internal/progress/progress.go index 1bf8aae57..7d86ba202 100644 --- a/internal/progress/progress.go +++ b/internal/progress/progress.go @@ -59,7 +59,7 @@ func (m progressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Quit case successMsg: - m.successMessage = msg.message + m.successMessage = msg.message + "\n\n" return m, tea.Quit case startProvision: @@ -108,11 +108,13 @@ func (m progressModel) View() string { completedSteps = completedSteps + renderMessage(fmt.Sprintf(":white_check_mark: %s", m.completedSteps[i])) } - return m.header + "\n\n" + - completedSteps + - m.nextStep + "\n\n" + - m.error + "\n\n" + if m.header != "" { + return m.header + "\n\n" + + completedSteps + + m.nextStep + "\n\n" + + m.error + "\n\n" + } } - return m.successMessage + "\n\n" + return m.successMessage } diff --git a/main.go b/main.go index 0abb13dc7..8e3aea3ea 100644 --- a/main.go +++ b/main.go @@ -13,6 +13,7 @@ import ( "time" "github.com/rs/zerolog" + "golang.org/x/exp/slices" "github.com/rs/zerolog/log" @@ -24,6 +25,21 @@ import ( ) func main() { + argsWithProg := os.Args + + bubbleTeaBlacklist := []string{"completion", "help", "--help", "-h"} + canRunBubbleTea := true + + if argsWithProg != nil { + for _, arg := range argsWithProg { + isBlackListed := slices.Contains(bubbleTeaBlacklist, arg) + + if isBlackListed { + canRunBubbleTea = false + } + } + } + now := time.Now() epoch := now.Unix() @@ -85,11 +101,16 @@ func main() { stdLog.Panicf("unable to set log-file-location, error is: %s", err) } - progress.InitializeProgressTerminal() + if canRunBubbleTea { + progress.InitializeProgressTerminal() - go func() { + go func() { + cmd.Execute() + }() + + progress.Progress.Run() + } else { cmd.Execute() - }() + } - progress.Progress.Run() }