Skip to content

Commit a9837f5

Browse files
committed
fix: clear progress line on interrupt
1 parent 0348ef8 commit a9837f5

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

runner/restore.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"os/signal"
7+
"strings"
78
"syscall"
89

910
"github.com/roie/netvs/wifi"
@@ -16,10 +17,14 @@ func RestoreOnSignal(w wifi.WiFi, original wifi.Network) {
1617
go func() {
1718
<-sig
1819
signal.Stop(sig)
19-
fmt.Fprintln(os.Stderr, "\ninterrupted — restoring original network...")
20-
if err := w.Restore(original); err != nil {
21-
fmt.Fprintf(os.Stderr, "warning: restore failed: %v\n", err)
20+
fmt.Print("\r" + strings.Repeat(" ", 60) + "\r\n")
21+
name := original.SSID
22+
if name == "" {
23+
fmt.Fprintln(os.Stderr, "Restoring connection...")
24+
} else {
25+
fmt.Fprintf(os.Stderr, "Restoring connection to %s...\n", name)
2226
}
27+
w.Restore(original)
2328
fmt.Print("\033[?25h")
2429
os.Exit(1)
2530
}()

0 commit comments

Comments
 (0)