func WithSpinner(ctx context.Context, msg ...string) func() {
	if os.Getenv("NO_COLOR") != "" {  
		log.G(ctx).Info(msg)
		return func() {}
	}
	ctx, cancel := context.WithCancel(ctx)
	s := spinner.New(
		spinnerCharSet,
		spinnerDuration,
	)
	if len(msg) > 0 {
		s.Prefix = msg[0]
	}
	go func() {
		s.Start()
		<-ctx.Done()
		s.Stop()
		fmt.Println("")
	}()
	return func() {
		cancel()
		time.Sleep(time.Millisecond * 100)
	}
}
WithSpinner create a spinner that prints a message and canceled if the
given context is canceled or the returned stop function is called.
package util
import (
	"context"
	"fmt"
	"os"
	"os/signal"
	"strings"
	"time"
	"github.com/argoproj-labs/argocd-autopilot/pkg/log"
	"github.com/argoproj-labs/argocd-autopilot/pkg/store"
	"github.com/briandowns/spinner"
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"k8s.io/client-go/tools/clientcmd"
)
const (
	yamlSeperator = "\n---\n"
	indentation   = "    "
)
var (
	spinnerCharSet  = spinner.CharSets[26]
	spinnerDuration = time.Millisecond * 500
)
func ContextWithCancelOnSignals(ctx context.Context, sigs ...os.Signal) context.Context {
	ctx, cancel := context.WithCancel(ctx)
	sig := make(chan os.Signal, 1)
	signal.Notify(sig, sigs...)
	go func() {
		cancels := 0
		for {
			s := <-sig
			cancels++
			if cancels == 1 {
				log.G(ctx).Printf("got signal: %s", s)
				cancel()
			} else {
				log.G(ctx).Printf("forcing exit")
				os.Exit(1)
			}
		}
	}()
	return ctx
}
func KubeContextToServer(contextName string) (string, error) {
	configAccess := clientcmd.NewDefaultPathOptions()
	conf, err := configAccess.GetStartingConfig()
	if err != nil {
		return "", err
	}
	ctx := conf.Contexts[contextName]
	if ctx == nil {
		return "", fmt.Errorf("Context %s does not exist in kubeconfig", contextName)
	}
	cluster := conf.Clusters[ctx.Cluster]
	if cluster == nil {
		return "", fmt.Errorf("Cluster %s does not exist in kubeconfig", ctx.Cluster)
	}
	return cluster.Server, nil
}
func Die(err error, cause ...string) {
	if err != nil {
		if len(cause) > 0 {
			panic(fmt.Errorf("%s: %w", cause[0], err))
		}
		panic(err)
	}
}