Merge pull request #380 from replicatedhq/divolgin/cursor

Make cursors visible on CTRL+C
This commit is contained in:
divolgin
2021-07-01 16:26:46 -07:00
committed by GitHub
2 changed files with 18 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"io/ioutil"
"net/http"
"os"
"os/signal"
"strings"
"time"
@@ -28,6 +29,14 @@ func runPreflights(v *viper.Viper, arg string) error {
fmt.Print(cursor.Hide())
defer fmt.Print(cursor.Show())
go func() {
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt)
<-signalChan
fmt.Print(cursor.Show())
os.Exit(0)
}()
var preflightContent []byte
var err error
if strings.HasPrefix(arg, "secret/") {

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"os/signal"
"net/url"
"os"
@@ -33,6 +34,14 @@ func runTroubleshoot(v *viper.Viper, arg string) error {
fmt.Print(cursor.Hide())
defer fmt.Print(cursor.Show())
go func() {
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt)
<-signalChan
fmt.Print(cursor.Show())
os.Exit(0)
}()
k8sConfig, err := k8sutil.GetRESTConfig()
if err != nil {
return errors.Wrap(err, "failed to convert kube flags to rest config")