Files
cli/pkg/ux/progressbar.go
zeekay 96715881cb go mod tidy
Update CLI for genesis

Fix import paths from ethereum/go-ethereum to luxfi/geth

- Replace all ethereum/go-ethereum imports with luxfi/geth
- Add local rawdb package for unexported constants
- Fix build errors in genesis tools
- Add comprehensive migration documentation
- Create build-all.sh script for building all tools
- Clean up duplicate functions and unused imports

Fix remaining imports

Update CLI

Remove symlink

Remove local replace directives

Update

Update old templates
2025-07-31 19:40:18 +00:00

48 lines
1.1 KiB
Go

// Copyright (C) 2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package ux
import (
"fmt"
"time"
ansi "github.com/k0kubun/go-ansi"
progressbar "github.com/schollz/progressbar/v3"
)
func TimedProgressBar(
duration time.Duration,
title string,
extraSteps int,
) (*progressbar.ProgressBar, error) {
const steps = 1000
stepDuration := duration / steps
bar := progressbar.NewOptions(steps+extraSteps,
progressbar.OptionSetWriter(ansi.NewAnsiStdout()),
progressbar.OptionEnableColorCodes(true),
progressbar.OptionSetElapsedTime(false),
progressbar.OptionSetWidth(15),
progressbar.OptionSetDescription(title),
progressbar.OptionSetTheme(progressbar.Theme{
Saucer: "[green]=[reset]",
SaucerHead: "[green]>[reset]",
SaucerPadding: " ",
BarStart: "[",
BarEnd: "]",
}))
for i := 0; i < steps; i++ {
if err := bar.Add(1); err != nil {
return nil, err
}
time.Sleep(stepDuration)
}
if extraSteps == 0 {
fmt.Println()
}
return bar, nil
}
func ExtraStepExecuted(bar *progressbar.ProgressBar) error {
return bar.Add(1)
}