mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 16:22: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.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.Author, "author", "GO Comic Converter", "Author of the epub")
|
||||||
c.AddStringParam(&c.Options.Title, "title", "", "Title 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.AddSection("Config")
|
||||||
c.AddStringParam(&c.Options.Profile, "profile", c.Options.Profile, fmt.Sprintf("Profile to use: \n%s", c.Options.AvailableProfiles()))
|
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.AddBoolParam(&c.Options.Reset, "reset", false, "Reset your parameters to default")
|
||||||
|
|
||||||
c.AddSection("Other")
|
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.Version, "version", false, "Show current and available version")
|
||||||
c.AddBoolParam(&c.Options.Help, "help", false, "Show this help message")
|
c.AddBoolParam(&c.Options.Help, "help", false, "Show this help message")
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,6 @@ type Options struct {
|
|||||||
Output string `yaml:"-"`
|
Output string `yaml:"-"`
|
||||||
Author string `yaml:"-"`
|
Author string `yaml:"-"`
|
||||||
Title string `yaml:"-"`
|
Title string `yaml:"-"`
|
||||||
Auto bool `yaml:"-"`
|
|
||||||
Workers int `yaml:"-"`
|
|
||||||
Dry bool `yaml:"-"`
|
|
||||||
DryVerbose bool `yaml:"-"`
|
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
Profile string `yaml:"profile"`
|
Profile string `yaml:"profile"`
|
||||||
@ -27,6 +23,7 @@ type Options struct {
|
|||||||
Crop bool `yaml:"crop"`
|
Crop bool `yaml:"crop"`
|
||||||
Brightness int `yaml:"brightness"`
|
Brightness int `yaml:"brightness"`
|
||||||
Contrast int `yaml:"contrast"`
|
Contrast int `yaml:"contrast"`
|
||||||
|
Auto bool `yaml:"-"`
|
||||||
AutoRotate bool `yaml:"auto_rotate"`
|
AutoRotate bool `yaml:"auto_rotate"`
|
||||||
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
AutoSplitDoublePage bool `yaml:"auto_split_double_page"`
|
||||||
NoBlankPage bool `yaml:"no_blank_page"`
|
NoBlankPage bool `yaml:"no_blank_page"`
|
||||||
@ -42,6 +39,10 @@ type Options struct {
|
|||||||
Reset bool `yaml:"-"`
|
Reset bool `yaml:"-"`
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
|
Workers int `yaml:"-"`
|
||||||
|
Dry bool `yaml:"-"`
|
||||||
|
DryVerbose bool `yaml:"-"`
|
||||||
|
Quiet bool `yaml:"-"`
|
||||||
Version bool `yaml:"-"`
|
Version bool `yaml:"-"`
|
||||||
Help bool `yaml:"-"`
|
Help bool `yaml:"-"`
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ type EpubOptions struct {
|
|||||||
Dry bool
|
Dry bool
|
||||||
DryVerbose bool
|
DryVerbose bool
|
||||||
SortPathMode int
|
SortPathMode int
|
||||||
|
Quiet bool
|
||||||
|
|
||||||
*ImageOptions
|
*ImageOptions
|
||||||
}
|
}
|
||||||
@ -211,7 +212,7 @@ func (e *ePub) Write() error {
|
|||||||
|
|
||||||
totalParts := len(epubParts)
|
totalParts := len(epubParts)
|
||||||
|
|
||||||
bar := NewBar(totalParts, "Writing Part", 2, 2)
|
bar := NewBar(e.Quiet, totalParts, "Writing Part", 2, 2)
|
||||||
for i, part := range epubParts {
|
for i, part := range epubParts {
|
||||||
ext := filepath.Ext(e.Output)
|
ext := filepath.Ext(e.Output)
|
||||||
suffix := ""
|
suffix := ""
|
||||||
|
@ -198,7 +198,7 @@ func (e *ePub) LoadImages() ([]*Image, error) {
|
|||||||
imageOutput := make(chan *Image)
|
imageOutput := make(chan *Image)
|
||||||
|
|
||||||
// processing
|
// processing
|
||||||
bar := NewBar(imageCount, "Processing", 1, 2)
|
bar := NewBar(e.Quiet, imageCount, "Processing", 1, 2)
|
||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
|
|
||||||
for i := 0; i < e.ImageOptions.Workers; i++ {
|
for i := 0; i < e.ImageOptions.Workers; i++ {
|
||||||
|
@ -7,7 +7,10 @@ import (
|
|||||||
"github.com/schollz/progressbar/v3"
|
"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)))
|
fmtJob := fmt.Sprintf("%%0%dd", len(fmt.Sprint(totalJob)))
|
||||||
fmtDesc := fmt.Sprintf("[%s/%s] %%-15s", fmtJob, fmtJob)
|
fmtDesc := fmt.Sprintf("[%s/%s] %%-15s", fmtJob, fmtJob)
|
||||||
return progressbar.NewOptions(max,
|
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,
|
Title: cmd.Options.Title,
|
||||||
Author: cmd.Options.Author,
|
Author: cmd.Options.Author,
|
||||||
StripFirstDirectoryFromToc: cmd.Options.StripFirstDirectoryFromToc,
|
StripFirstDirectoryFromToc: cmd.Options.StripFirstDirectoryFromToc,
|
||||||
Dry: cmd.Options.Dry,
|
|
||||||
DryVerbose: cmd.Options.DryVerbose,
|
|
||||||
SortPathMode: cmd.Options.SortPathMode,
|
SortPathMode: cmd.Options.SortPathMode,
|
||||||
ImageOptions: &epub.ImageOptions{
|
ImageOptions: &epub.ImageOptions{
|
||||||
ViewWidth: perfectWidth,
|
ViewWidth: perfectWidth,
|
||||||
@ -117,6 +115,9 @@ $ go install github.com/celogeek/go-comic-converter/v%d@%s
|
|||||||
HasCover: cmd.Options.HasCover,
|
HasCover: cmd.Options.HasCover,
|
||||||
Workers: cmd.Options.Workers,
|
Workers: cmd.Options.Workers,
|
||||||
},
|
},
|
||||||
|
Dry: cmd.Options.Dry,
|
||||||
|
DryVerbose: cmd.Options.DryVerbose,
|
||||||
|
Quiet: cmd.Options.Quiet,
|
||||||
}).Write(); err != nil {
|
}).Write(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user