From 1b1efcd3c1b0685a9d7decccd20d685587e94ad7 Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Fri, 11 Apr 2025 17:55:02 +0200 Subject: [PATCH] feat: improved output and errors --- cmd/gogitlabber/git.go | 13 +++---------- cmd/gogitlabber/output.go | 18 +++--------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/cmd/gogitlabber/git.go b/cmd/gogitlabber/git.go index 7ebc508..f050c1d 100644 --- a/cmd/gogitlabber/git.go +++ b/cmd/gogitlabber/git.go @@ -79,11 +79,7 @@ func checkoutRepositories(repositories []Repository, concurrency int) { mu.Lock() clonedCount++ if !debug { - // update the progress bar - descriptionPrefixPre := "Cloning repository " - descriptionPrefix := descriptionPrefixPre + repoName + " ..." - bar.Describe(descriptionPrefix) - progressBarAdd(1) + bar.Add(1) } mu.Unlock() @@ -92,10 +88,7 @@ func checkoutRepositories(repositories []Repository, concurrency int) { logger.Print("Decided to pull repository: "+repoName, nil) pullRepository(repoName, repoDestination) if !debug { - descriptionPrefixPre := "Pulling repository " - descriptionPrefix := descriptionPrefixPre + repoName + " ..." - bar.Describe(descriptionPrefix) - progressBarAdd(1) + bar.Add(1) } default: @@ -106,7 +99,7 @@ func checkoutRepositories(repositories []Repository, concurrency int) { mu.Lock() errorCount++ if !debug { - progressBarAdd(1) + bar.Add(1) } mu.Unlock() } diff --git a/cmd/gogitlabber/output.go b/cmd/gogitlabber/output.go index 070c153..6f7953e 100644 --- a/cmd/gogitlabber/output.go +++ b/cmd/gogitlabber/output.go @@ -13,15 +13,16 @@ var bar *progressbar.ProgressBar func progressBar() { // configure progressbar - bar = progressbar.NewOptions(2, + bar = progressbar.NewOptions(100, progressbar.OptionEnableColorCodes(true), - progressbar.OptionSetDescription("Logging into Git..."), + progressbar.OptionSetDescription("..."), progressbar.OptionSetElapsedTime(false), progressbar.OptionSetPredictTime(false), progressbar.OptionSetWidth(20), progressbar.OptionSetWriter(ansi.NewAnsiStdout()), progressbar.OptionShowCount(), progressbar.OptionShowDescriptionAtLineEnd(), + progressbar.OptionShowElapsedTimeOnFinish(), progressbar.OptionSetTheme(progressbar.Theme{ Saucer: "[green]=[reset]", SaucerHead: "[green]>[reset]", @@ -31,20 +32,7 @@ func progressBar() { }), ) - // initialize progressbar logger.Print("Initialize progressbar", nil) - err := bar.RenderBlank() - progressBarAdd(1) - if err != nil { - logger.Fatal("Initialization of the progressbar failed", err) - } -} - -func progressBarAdd(amount int) { - logger.Print("BAR: Progressing the bar", nil) - if err := bar.Add(amount); err != nil { - logger.Print("BAR: Could not update the bar", err) - } } func printSummary() {