mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 16:22:37 +02:00
simplify a bit
This commit is contained in:
parent
63f980e4cb
commit
61ee576465
@ -4,6 +4,7 @@ create a progress bar with custom settings.
|
|||||||
package epubprogress
|
package epubprogress
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@ -31,7 +32,10 @@ func New(o Options) epubProgress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if o.Json {
|
if o.Json {
|
||||||
return newEpubProgressJson(o)
|
return &epubProgressJson{
|
||||||
|
o: o,
|
||||||
|
e: json.NewEncoder(os.Stdout),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmtJob := fmt.Sprintf("%%0%dd", len(fmt.Sprint(o.TotalJob)))
|
fmtJob := fmt.Sprintf("%%0%dd", len(fmt.Sprint(o.TotalJob)))
|
||||||
|
@ -2,7 +2,6 @@ package epubprogress
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type epubProgressJson struct {
|
type epubProgressJson struct {
|
||||||
@ -11,13 +10,6 @@ type epubProgressJson struct {
|
|||||||
current int
|
current int
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEpubProgressJson(o Options) epubProgress {
|
|
||||||
return &epubProgressJson{
|
|
||||||
o: o,
|
|
||||||
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{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user