feat: comply with linter for the first time

This commit is contained in:
Simon Cornet 2025-03-04 06:37:43 +01:00
commit 77d17d97b5
2 changed files with 12 additions and 4 deletions

View file

@ -49,18 +49,19 @@ func checkoutRepositories(repositories []Repository) {
log.Printf("error: %v", err) log.Printf("error: %v", err)
} }
clonedCount = clonedCount + 1 clonedCount = clonedCount + 1
bar.Add(1) progressBarAdd(1)
// pull the latest // pull the latest
} else if strings.Contains(string(repoStatus), url) { } else if strings.Contains(string(repoStatus), url) {
pullRepository(repoName, repoDestination) pullRepository(repoName, repoDestination)
bar.Add(1) progressBarAdd(1)
// report error if not cloned or pulled repository // report error if not cloned or pulled repository
} else { } else {
log.Printf("error: decided not to clone or pull repository %v\n", repoName) log.Printf("error: decided not to clone or pull repository %v\n", repoName)
log.Printf("error: this is why: %v\n", repoStatus) log.Printf("error: this is why: %v\n", repoStatus)
errorCount = errorCount + 1 errorCount = errorCount + 1
progressBarAdd(1)
} }
} }
} }

View file

@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"log"
"github.com/k0kubun/go-ansi" "github.com/k0kubun/go-ansi"
"github.com/schollz/progressbar/v3" "github.com/schollz/progressbar/v3"
@ -13,9 +14,9 @@ func progressBar(repositories []Repository) {
repoCount := len(repositories) repoCount := len(repositories)
// make progressbar // make progressbar
barPrefix := fmt.Sprintf("Getting your one and only repository...") barPrefix := "Getting your one and only repository..."
if repoCount > 1 { if repoCount > 1 {
barPrefix = fmt.Sprintf("Getting your repositories...") barPrefix = "Getting your repositories..."
} }
bar = progressbar.NewOptions( bar = progressbar.NewOptions(
@ -38,6 +39,12 @@ func progressBar(repositories []Repository) {
) )
} }
func progressBarAdd(amount int) {
if err := bar.Add(amount); err != nil {
log.Printf("Progress bar update error: %v", err)
}
}
func printSummary() { func printSummary() {
fmt.Println("") fmt.Println("")