mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 00:02:37 +02:00
add quiet mode
This commit is contained in:
parent
a3851475d2
commit
9cf733b553
@ -79,9 +79,6 @@ func (c *Converter) InitParse() {
|
||||
c.AddStringParam(&c.Options.Output, "output", "", "Output of the epub (directory or epub): (default [INPUT].epub)")
|
||||
c.AddStringParam(&c.Options.Author, "author", "GO Comic Converter", "Author of the epub")
|
||||
c.AddStringParam(&c.Options.Title, "title", "", "Title of the epub")
|
||||
c.AddIntParam(&c.Options.Workers, "workers", runtime.NumCPU(), "Number of workers")
|
||||
c.AddBoolParam(&c.Options.Dry, "dry", false, "Dry run to show all options")
|
||||
c.AddBoolParam(&c.Options.DryVerbose, "dry-verbose", false, "Display also sorted files after the TOC")
|
||||
|
||||
c.AddSection("Config")
|
||||
c.AddStringParam(&c.Options.Profile, "profile", c.Options.Profile, fmt.Sprintf("Profile to use: \n%s", c.Options.AvailableProfiles()))
|
||||
@ -105,6 +102,10 @@ func (c *Converter) InitParse() {
|
||||
c.AddBoolParam(&c.Options.Reset, "reset", false, "Reset your parameters to default")
|
||||
|
||||
c.AddSection("Other")
|
||||
c.AddIntParam(&c.Options.Workers, "workers", runtime.NumCPU(), "Number of workers")
|
||||
c.AddBoolParam(&c.Options.Dry, "dry", false, "Dry run to show all options")
|
||||
c.AddBoolParam(&c.Options.DryVerbose, "dry-verbose", false, "Display also sorted files after the TOC")
|
||||
c.AddBoolParam(&c.Options.Quiet, "quiet", false, "Disable progress bar")
|
||||
c.AddBoolParam(&c.Options.Version, "version", false, "Show current and available version")
|
||||
c.AddBoolParam(&c.Options.Help, "help", false, "Show this help message")
|
||||
}
|
||||
|
@ -12,14 +12,10 @@ import (
|
||||
|
||||
type Options struct {
|
||||
// Output
|
||||
Input string `yaml:"-"`
|
||||
Output string `yaml:"-"`
|
||||
Author string `yaml:"-"`
|
||||
Title string `yaml:"-"`
|
||||
Auto bool `yaml:"-"`
|
||||
Workers int `yaml:"-"`
|
||||
Dry bool `yaml:"-"`
|
||||
DryVerbose bool `yaml:"-"`
|
||||
Input string `yaml:"-"`
|
||||
Output string `yaml:"-"`
|
||||
Author string `yaml:"-"`
|
||||
Title string `yaml:"-"`
|
||||
|
||||
// Config
|
||||
Profile string `yaml:"profile"`
|
||||
@ -27,6 +23,7 @@ type Options struct {
|
||||
Crop bool `yaml:"crop"`
|
||||
Brightness int `yaml:"brightness"`
|
||||
Contrast int `yaml:"contrast"`
|
||||
Auto bool `yaml:"-"`
|
||||
AutoRotate bool `yaml:"auto_rotate"`
|
||||
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
||||
NoBlankPage bool `yaml:"no_blank_page"`
|
||||
@ -42,8 +39,12 @@ type Options struct {
|
||||
Reset bool `yaml:"-"`
|
||||
|
||||
// Other
|
||||
Version bool `yaml:"-"`
|
||||
Help bool `yaml:"-"`
|
||||
Workers int `yaml:"-"`
|
||||
Dry bool `yaml:"-"`
|
||||
DryVerbose bool `yaml:"-"`
|
||||
Quiet bool `yaml:"-"`
|
||||
Version bool `yaml:"-"`
|
||||
Help bool `yaml:"-"`
|
||||
|
||||
// Internal
|
||||
profiles profiles.Profiles
|
||||
|
@ -39,6 +39,7 @@ type EpubOptions struct {
|
||||
Dry bool
|
||||
DryVerbose bool
|
||||
SortPathMode int
|
||||
Quiet bool
|
||||
|
||||
*ImageOptions
|
||||
}
|
||||
@ -211,7 +212,7 @@ func (e *ePub) Write() error {
|
||||
|
||||
totalParts := len(epubParts)
|
||||
|
||||
bar := NewBar(totalParts, "Writing Part", 2, 2)
|
||||
bar := NewBar(e.Quiet, totalParts, "Writing Part", 2, 2)
|
||||
for i, part := range epubParts {
|
||||
ext := filepath.Ext(e.Output)
|
||||
suffix := ""
|
||||
|
@ -198,7 +198,7 @@ func (e *ePub) LoadImages() ([]*Image, error) {
|
||||
imageOutput := make(chan *Image)
|
||||
|
||||
// processing
|
||||
bar := NewBar(imageCount, "Processing", 1, 2)
|
||||
bar := NewBar(e.Quiet, imageCount, "Processing", 1, 2)
|
||||
wg := &sync.WaitGroup{}
|
||||
|
||||
for i := 0; i < e.ImageOptions.Workers; i++ {
|
||||
|
@ -7,7 +7,10 @@ import (
|
||||
"github.com/schollz/progressbar/v3"
|
||||
)
|
||||
|
||||
func NewBar(max int, description string, currentJob, totalJob int) *progressbar.ProgressBar {
|
||||
func NewBar(quiet bool, max int, description string, currentJob, totalJob int) *progressbar.ProgressBar {
|
||||
if quiet {
|
||||
return progressbar.DefaultSilent(int64(max))
|
||||
}
|
||||
fmtJob := fmt.Sprintf("%%0%dd", len(fmt.Sprint(totalJob)))
|
||||
fmtDesc := fmt.Sprintf("[%s/%s] %%-15s", fmtJob, fmtJob)
|
||||
return progressbar.NewOptions(max,
|
||||
|
5
main.go
5
main.go
@ -100,8 +100,6 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
||||
Title: cmd.Options.Title,
|
||||
Author: cmd.Options.Author,
|
||||
StripFirstDirectoryFromToc: cmd.Options.StripFirstDirectoryFromToc,
|
||||
Dry: cmd.Options.Dry,
|
||||
DryVerbose: cmd.Options.DryVerbose,
|
||||
SortPathMode: cmd.Options.SortPathMode,
|
||||
ImageOptions: &epub.ImageOptions{
|
||||
ViewWidth: perfectWidth,
|
||||
@ -117,6 +115,9 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
||||
HasCover: cmd.Options.HasCover,
|
||||
Workers: cmd.Options.Workers,
|
||||
},
|
||||
Dry: cmd.Options.Dry,
|
||||
DryVerbose: cmd.Options.DryVerbose,
|
||||
Quiet: cmd.Options.Quiet,
|
||||
}).Write(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user