mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 08:12:36 +02:00
improve err and help
This commit is contained in:
parent
8be50a99a6
commit
14f4ab2b81
@ -136,7 +136,7 @@ func loadDir(input string) (int, chan *imageTask, error) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
if len(images) == 0 {
|
if len(images) == 0 {
|
||||||
@ -151,7 +151,7 @@ func loadDir(input string) (int, chan *imageTask, error) {
|
|||||||
for i, img := range images {
|
for i, img := range images {
|
||||||
f, err := os.Open(img)
|
f, err := os.Open(img)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
output <- &imageTask{
|
output <- &imageTask{
|
||||||
@ -194,7 +194,7 @@ func loadCbz(input string) (int, chan *imageTask, error) {
|
|||||||
for i, img := range images {
|
for i, img := range images {
|
||||||
f, err := img.Open()
|
f, err := img.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
output <- &imageTask{
|
output <- &imageTask{
|
||||||
|
16
main.go
16
main.go
@ -124,10 +124,14 @@ func main() {
|
|||||||
flag.IntVar(&opt.Quality, "quality", 85, "Quality of the image")
|
flag.IntVar(&opt.Quality, "quality", 85, "Quality of the image")
|
||||||
flag.BoolVar(&opt.NoCrop, "nocrop", false, "Disable cropping")
|
flag.BoolVar(&opt.NoCrop, "nocrop", false, "Disable cropping")
|
||||||
flag.IntVar(&opt.LimitMb, "limitmb", 0, "Limit size of the ePub: Default nolimit (0), Minimum 20")
|
flag.IntVar(&opt.LimitMb, "limitmb", 0, "Limit size of the ePub: Default nolimit (0), Minimum 20")
|
||||||
|
flag.Usage = func() {
|
||||||
|
fmt.Fprintf(os.Stderr, "Usage of %s:\n", filepath.Base(os.Args[0]))
|
||||||
|
flag.PrintDefaults()
|
||||||
|
}
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if opt.Input == "" {
|
if opt.Input == "" {
|
||||||
fmt.Println("Missing input or output!")
|
fmt.Fprintln(os.Stderr, "Missing input or output!")
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -135,7 +139,7 @@ func main() {
|
|||||||
if opt.Output == "" {
|
if opt.Output == "" {
|
||||||
fi, err := os.Stat(opt.Input)
|
fi, err := os.Stat(opt.Input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -149,14 +153,14 @@ func main() {
|
|||||||
|
|
||||||
profileIdx, profileMatch := ProfilesIdx[opt.Profile]
|
profileIdx, profileMatch := ProfilesIdx[opt.Profile]
|
||||||
if !profileMatch {
|
if !profileMatch {
|
||||||
fmt.Println("Profile doesn't exists!")
|
fmt.Fprintln(os.Stderr, "Profile doesn't exists!")
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
profile := Profiles[profileIdx]
|
profile := Profiles[profileIdx]
|
||||||
|
|
||||||
if opt.LimitMb > 0 && opt.LimitMb < 20 {
|
if opt.LimitMb > 0 && opt.LimitMb < 20 {
|
||||||
fmt.Println("LimitMb should be 0 or >= 20")
|
fmt.Fprintln(os.Stderr, "LimitMb should be 0 or >= 20")
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -165,7 +169,7 @@ func main() {
|
|||||||
opt.Title = filepath.Base(opt.Input)
|
opt.Title = filepath.Base(opt.Input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(opt)
|
fmt.Fprintln(os.Stderr, opt)
|
||||||
|
|
||||||
if err := epub.NewEpub(&epub.EpubOptions{
|
if err := epub.NewEpub(&epub.EpubOptions{
|
||||||
Input: opt.Input,
|
Input: opt.Input,
|
||||||
@ -180,7 +184,7 @@ func main() {
|
|||||||
Crop: !opt.NoCrop,
|
Crop: !opt.NoCrop,
|
||||||
},
|
},
|
||||||
}).Write(); err != nil {
|
}).Write(); err != nil {
|
||||||
fmt.Printf("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