From 409309442e8a94895014af3af85b0aa73b29d987 Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Fri, 24 Apr 2015 12:01:28 -0700 Subject: [PATCH] fix scrolling progressbar bug --- cmd-common.go | 2 +- pkg/console/console.go | 21 ++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cmd-common.go b/cmd-common.go index aa5149eb..aa1b0f36 100644 --- a/cmd-common.go +++ b/cmd-common.go @@ -59,7 +59,7 @@ func startBar(size int64) *pb.ProgressBar { bar.ShowSpeed = true bar.Callback = func(s string) { // Colorize - console.Info("\r" + s) + console.Print("\r" + s) } // Feels like wget bar.Format("[=> ]") diff --git a/pkg/console/console.go b/pkg/console/console.go index 85a9c43d..849a5efc 100644 --- a/pkg/console/console.go +++ b/pkg/console/console.go @@ -37,15 +37,19 @@ var ( // currTheme is current theme currThemeName = GetDefaultThemeName() + // Print prints a error message and exits + Print = themesDB[currThemeName].Info.Print + // Println prints a error message with a new line and exits + Println = themesDB[currThemeName].Info.Println + // Printf prints a error message with formatting and exits + Printf = themesDB[currThemeName].Info.Printf + // Fatal prints a error message and exits Fatal = func(a ...interface{}) { print(themesDB[currThemeName].Fatal, a...); os.Exit(1) } // Fatalln prints a error message with a new line and exits Fatalln = func(a ...interface{}) { println(themesDB[currThemeName].Fatal, a...); os.Exit(1) } // Fatalf prints a error message with formatting and exits - Fatalf = func(f string, a ...interface{}) { - printf(themesDB[currThemeName].Fatal, f, a...) - os.Exit(1) - } + Fatalf = func(f string, a ...interface{}) { printf(themesDB[currThemeName].Fatal, f, a...); os.Exit(1) } // Error prints a error message Error = func(a ...interface{}) { print(themesDB[currThemeName].Error, a...) } @@ -122,11 +126,8 @@ var ( mutex.Unlock() default: mutex.Lock() - output := color.Output - color.Output = os.Stderr c.Print(ProgramName() + ": ") c.Print(a...) - color.Output = output mutex.Unlock() } } @@ -160,11 +161,8 @@ var ( mutex.Unlock() default: mutex.Lock() - output := color.Output - color.Output = os.Stderr c.Print(ProgramName() + ": ") c.Println(a...) - color.Output = output mutex.Unlock() } } @@ -198,11 +196,8 @@ var ( mutex.Unlock() default: mutex.Lock() - output := color.Output - color.Output = os.Stderr c.Print(ProgramName() + ": ") c.Printf(f, a...) - color.Output = output mutex.Unlock() } }