From fdda1aa57e3e43dc8c7a1e7a9e403155f34dd102 Mon Sep 17 00:00:00 2001 From: Patrick G Date: Sun, 17 Dec 2017 11:44:24 -0500 Subject: [PATCH] Fix mistake in last commit --- kepubify.go | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/kepubify.go b/kepubify.go index 789008f..cce5154 100644 --- a/kepubify.go +++ b/kepubify.go @@ -126,20 +126,7 @@ func main() { if strings.HasSuffix(src, ".kepub.epub") { errExit("Input file is already a kepub.\n") } else if strings.HasSuffix(src, ".epub") { - if isFile(dest) { - if strings.HasSuffix(dest, ".kepub.epub") { - fmt.Printf("Converting '%s' to '%s'\n\n", os.Args[1], os.Args[2]) - - err = kepub.Kepubify(src, dest, true) - if err != nil { - errExit("Error converting file: %v\n", err) - } - - msgExit("\nSuccessfully converted '%s' to '%s'\n", os.Args[1], os.Args[2]) - } else { - errExit("Output file must end with .kepub.epub. See kepubify --help for more details.\n") - } - } else if isDir(dest) { + if isDir(dest) { dest = filepath.Join(dest, fmt.Sprintf("%s.kepub.epub", strings.Replace(filepath.Base(src), ".epub", "", -1))) fmt.Printf("Converting '%s' to '%s'\n\n", os.Args[1], dest) @@ -150,10 +137,17 @@ func main() { } msgExit("\nSuccessfully converted '%s' to '%s'\n", os.Args[1], dest) - } else if !exists(dest) { - errExit("Output '%s' does not exist.\n", dest) + } else if strings.HasSuffix(dest, ".kepub.epub") { + fmt.Printf("Converting '%s' to '%s'\n\n", os.Args[1], os.Args[2]) + + err = kepub.Kepubify(src, dest, true) + if err != nil { + errExit("Error converting file: %v\n", err) + } + + msgExit("\nSuccessfully converted '%s' to '%s'\n", os.Args[1], os.Args[2]) } else { - msgExit("Output must be nothing, or a directory. See kepubify --help for more details.\n") + errExit("Output file must end with .kepub.epub. See kepubify --help for more details.\n") } } else { errExit("Input file must end with .epub. See kepubify --help for more details.\n")