feat: initialize progressbar earlier
This commit is contained in:
parent
d3944e67b4
commit
f22da9364c
3 changed files with 25 additions and 20 deletions
|
|
@ -58,6 +58,10 @@ func fetchRepositoriesGitlab() ([]Repository, error) {
|
|||
return repositories, fmt.Errorf("ERROR: no repositories found\n")
|
||||
}
|
||||
|
||||
repoCount := len(repositories)
|
||||
bar.Set(0)
|
||||
bar.ChangeMax(repoCount)
|
||||
|
||||
logPrint("HTTP: Returning repositories found", nil)
|
||||
return repositories, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,18 +37,18 @@ func main() {
|
|||
}
|
||||
logPrint("VALIDATION: git found in path", nil)
|
||||
|
||||
// make initial progressbar
|
||||
if !debug {
|
||||
progressBar()
|
||||
log.SetOutput(io.Discard)
|
||||
}
|
||||
|
||||
// fetch repository information from gitlab
|
||||
repositories, err := fetchRepositoriesGitlab()
|
||||
if err != nil {
|
||||
logFatal("FATAL: %v", err)
|
||||
}
|
||||
|
||||
// print progressbar ony if not in debug mode
|
||||
if !debug {
|
||||
progressBar(repositories)
|
||||
log.SetOutput(io.Discard)
|
||||
}
|
||||
|
||||
// manage found repositories
|
||||
checkoutRepositories(repositories, concurrency)
|
||||
printSummary()
|
||||
|
|
|
|||
|
|
@ -10,25 +10,18 @@ import (
|
|||
|
||||
var bar *progressbar.ProgressBar
|
||||
|
||||
func progressBar(repositories []Repository) {
|
||||
repoCount := len(repositories)
|
||||
func progressBar() {
|
||||
|
||||
// make progressbar
|
||||
barPrefix := "Getting your one and only repository..."
|
||||
if repoCount > 1 {
|
||||
barPrefix = "Getting your repositories..."
|
||||
}
|
||||
|
||||
bar = progressbar.NewOptions(
|
||||
repoCount,
|
||||
progressbar.OptionSetWriter(ansi.NewAnsiStdout()),
|
||||
// configure progressbar
|
||||
bar = progressbar.NewOptions(2,
|
||||
progressbar.OptionEnableColorCodes(true),
|
||||
progressbar.OptionShowCount(),
|
||||
progressbar.OptionShowDescriptionAtLineEnd(),
|
||||
progressbar.OptionSetDescription("Logging into Gitlab..."),
|
||||
progressbar.OptionSetElapsedTime(false),
|
||||
progressbar.OptionSetPredictTime(false),
|
||||
progressbar.OptionSetWidth(20),
|
||||
progressbar.OptionSetDescription(barPrefix),
|
||||
progressbar.OptionSetWriter(ansi.NewAnsiStdout()),
|
||||
progressbar.OptionShowCount(),
|
||||
progressbar.OptionShowDescriptionAtLineEnd(),
|
||||
progressbar.OptionSetTheme(progressbar.Theme{
|
||||
Saucer: "[green]=[reset]",
|
||||
SaucerHead: "[green]>[reset]",
|
||||
|
|
@ -37,6 +30,14 @@ func progressBar(repositories []Repository) {
|
|||
BarEnd: "]",
|
||||
}),
|
||||
)
|
||||
|
||||
// initialize progressbar
|
||||
logPrint("Initialize progressbar", nil)
|
||||
err := bar.RenderBlank()
|
||||
progressBarAdd(1)
|
||||
if err != nil {
|
||||
logFatal("Initialization of the progressbar failed", err)
|
||||
}
|
||||
}
|
||||
|
||||
func progressBarAdd(amount int) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue