@@ -3,6 +3,7 @@ package cli
33import (
44 "fmt"
55 "os"
6+ "runtime"
67
78 pb "github.com/cheggaaa/pb/v3"
89 "github.com/manifoldco/promptui"
@@ -31,19 +32,26 @@ func getConfirm(label string, auto bool) local.ConfirmDiffFunc {
3132}
3233
3334func handleEvents (events chan local.Event ) {
34- bar := pb .New (0 )
35- bar .Set (pb .Bytes , true )
36-
37- tmp := `{{string . "prefix"}}{{counters . }} {{bar . "[" "=" ">" "-" "]"}} {{percent . }} {{etime . }}{{string . "suffix"}}`
38- bar .SetTemplate (pb .ProgressBarTemplate (tmp ))
35+ var bar * pb.ProgressBar
36+ if runtime .GOOS != "windows" {
37+ bar = pb .New (0 )
38+ bar .Set (pb .Bytes , true )
39+ tmp := `{{string . "prefix"}}{{counters . }} {{bar . "[" "=" ">" "-" "]"}} {{percent . }} {{etime . }}{{string . "suffix"}}`
40+ bar .SetTemplate (pb .ProgressBarTemplate (tmp ))
41+ }
3942
4043 clear := func () {
41- _ , _ = fmt .Fprintf (os .Stderr , "\033 [2K\r " )
44+ if bar != nil {
45+ _ , _ = fmt .Fprintf (os .Stderr , "\033 [2K\r " )
46+ }
4247 }
4348
4449 for e := range events {
4550 switch e .Type {
4651 case local .EventProgress :
52+ if bar == nil {
53+ continue
54+ }
4755 bar .SetTotal (e .Size )
4856 bar .SetCurrent (e .Complete )
4957 if ! bar .IsStarted () {
@@ -58,13 +66,13 @@ func handleEvents(events chan local.Event) {
5866 e .Path ,
5967 formatBytes (e .Size , false ),
6068 )
61- if bar .IsStarted () {
69+ if bar != nil && bar .IsStarted () {
6270 bar .Write ()
6371 }
6472 case local .EventFileRemoved :
6573 clear ()
6674 _ , _ = fmt .Fprintf (os .Stdout , "- %s\n " , e .Path )
67- if bar .IsStarted () {
75+ if bar != nil && bar .IsStarted () {
6876 bar .Write ()
6977 }
7078 }
0 commit comments