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