mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 16:22:37 +02:00
move epubprogress outside epub
This commit is contained in:
parent
98aa128f3e
commit
63f980e4cb
@ -18,10 +18,10 @@ import (
|
|||||||
epubimage "github.com/celogeek/go-comic-converter/v2/pkg/epub/image"
|
epubimage "github.com/celogeek/go-comic-converter/v2/pkg/epub/image"
|
||||||
epubimageprocessor "github.com/celogeek/go-comic-converter/v2/pkg/epub/imageprocessor"
|
epubimageprocessor "github.com/celogeek/go-comic-converter/v2/pkg/epub/imageprocessor"
|
||||||
epuboptions "github.com/celogeek/go-comic-converter/v2/pkg/epub/options"
|
epuboptions "github.com/celogeek/go-comic-converter/v2/pkg/epub/options"
|
||||||
epubprogress "github.com/celogeek/go-comic-converter/v2/pkg/epub/progress"
|
|
||||||
epubtemplates "github.com/celogeek/go-comic-converter/v2/pkg/epub/templates"
|
epubtemplates "github.com/celogeek/go-comic-converter/v2/pkg/epub/templates"
|
||||||
epubtree "github.com/celogeek/go-comic-converter/v2/pkg/epub/tree"
|
epubtree "github.com/celogeek/go-comic-converter/v2/pkg/epub/tree"
|
||||||
epubzip "github.com/celogeek/go-comic-converter/v2/pkg/epub/zip"
|
epubzip "github.com/celogeek/go-comic-converter/v2/pkg/epub/zip"
|
||||||
|
"github.com/celogeek/go-comic-converter/v2/pkg/epubprogress"
|
||||||
"github.com/gofrs/uuid"
|
"github.com/gofrs/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ import (
|
|||||||
epubimage "github.com/celogeek/go-comic-converter/v2/pkg/epub/image"
|
epubimage "github.com/celogeek/go-comic-converter/v2/pkg/epub/image"
|
||||||
epubimagefilters "github.com/celogeek/go-comic-converter/v2/pkg/epub/imagefilters"
|
epubimagefilters "github.com/celogeek/go-comic-converter/v2/pkg/epub/imagefilters"
|
||||||
epuboptions "github.com/celogeek/go-comic-converter/v2/pkg/epub/options"
|
epuboptions "github.com/celogeek/go-comic-converter/v2/pkg/epub/options"
|
||||||
epubprogress "github.com/celogeek/go-comic-converter/v2/pkg/epub/progress"
|
|
||||||
epubzip "github.com/celogeek/go-comic-converter/v2/pkg/epub/zip"
|
epubzip "github.com/celogeek/go-comic-converter/v2/pkg/epub/zip"
|
||||||
|
"github.com/celogeek/go-comic-converter/v2/pkg/epubprogress"
|
||||||
"github.com/disintegration/gift"
|
"github.com/disintegration/gift"
|
||||||
)
|
)
|
||||||
|
|
@ -20,12 +20,12 @@ type Options struct {
|
|||||||
TotalJob int
|
TotalJob int
|
||||||
}
|
}
|
||||||
|
|
||||||
type EpubProgress interface {
|
type epubProgress interface {
|
||||||
Add(num int) error
|
Add(num int) error
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(o Options) EpubProgress {
|
func New(o Options) epubProgress {
|
||||||
if o.Quiet {
|
if o.Quiet {
|
||||||
return progressbar.DefaultSilent(int64(o.Max))
|
return progressbar.DefaultSilent(int64(o.Max))
|
||||||
}
|
}
|
@ -5,20 +5,20 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type EpubProgressJson struct {
|
type epubProgressJson struct {
|
||||||
o Options
|
o Options
|
||||||
e *json.Encoder
|
e *json.Encoder
|
||||||
current int
|
current int
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEpubProgressJson(o Options) EpubProgress {
|
func newEpubProgressJson(o Options) epubProgress {
|
||||||
return &EpubProgressJson{
|
return &epubProgressJson{
|
||||||
o: o,
|
o: o,
|
||||||
e: json.NewEncoder(os.Stdout),
|
e: json.NewEncoder(os.Stdout),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *EpubProgressJson) Add(num int) error {
|
func (p *epubProgressJson) Add(num int) error {
|
||||||
p.current += num
|
p.current += num
|
||||||
p.e.Encode(map[string]any{
|
p.e.Encode(map[string]any{
|
||||||
"type": "progress",
|
"type": "progress",
|
||||||
@ -37,6 +37,6 @@ func (p *EpubProgressJson) Add(num int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *EpubProgressJson) Close() error {
|
func (p *epubProgressJson) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user