mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-24 15:52:38 +02:00
add throttling and interface
This commit is contained in:
parent
77d6600a36
commit
4a3fc60732
@ -6,6 +6,7 @@ package epubprogress
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/schollz/progressbar/v3"
|
||||
)
|
||||
@ -18,7 +19,12 @@ type Options struct {
|
||||
TotalJob int
|
||||
}
|
||||
|
||||
func New(o Options) *progressbar.ProgressBar {
|
||||
type EpubProgress interface {
|
||||
Add(num int) error
|
||||
Close() (err error)
|
||||
}
|
||||
|
||||
func New(o Options) EpubProgress {
|
||||
if o.Quiet {
|
||||
return progressbar.DefaultSilent(int64(o.Max))
|
||||
}
|
||||
@ -26,6 +32,7 @@ func New(o Options) *progressbar.ProgressBar {
|
||||
fmtDesc := fmt.Sprintf("[%s/%s] %%-15s", fmtJob, fmtJob)
|
||||
return progressbar.NewOptions(o.Max,
|
||||
progressbar.OptionSetWriter(os.Stderr),
|
||||
progressbar.OptionThrottle(65*time.Millisecond),
|
||||
progressbar.OptionOnCompletion(func() {
|
||||
fmt.Fprint(os.Stderr, "\n")
|
||||
}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user