simplify a bit

This commit is contained in:
Celogeek 2024-01-04 17:01:17 +01:00
parent 63f980e4cb
commit 61ee576465
Signed by: celogeek
SSH Key Fingerprint: SHA256:DEDfxIK2nUWXbslbRkww3zsauDjhWHlTXar+ak4lDJ4
2 changed files with 5 additions and 9 deletions

View File

@ -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)))

View File

@ -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{