epubname 2.3.1 → 2.3.2
raw patch · 3 files changed
+15/−3 lines, 3 files
Files
- epubname.cabal +1/−1
- src/EpubName/Opts.hs +6/−1
- src/epubname.hs +8/−1
epubname.cabal view
@@ -1,6 +1,6 @@ name: epubname cabal-version: >= 1.2-version: 2.3.1+version: 2.3.2 build-type: Simple license: BSD3 license-file: LICENSE
src/EpubName/Opts.hs view
@@ -18,6 +18,7 @@ data Options = Options { optHelp :: Bool , optNoAction :: Bool+ , optOverwrite :: Bool , optPublisher :: Bool , optVerbose :: Maybe Int , optYear :: Bool@@ -28,6 +29,7 @@ defaultOptions = Options { optHelp = False , optNoAction = False+ , optOverwrite = False , optPublisher = False , optVerbose = Nothing , optYear = True@@ -42,6 +44,9 @@ , Option ['n'] ["no-action"] (NoArg (\opts -> opts { optNoAction = True } )) "Display what would be done, but do nothing"+ , Option ['o'] ["overwrite"]+ (NoArg (\opts -> opts { optOverwrite = True } )) + "Overwrite existing file with new name" , Option ['p'] ["publisher"] (NoArg (\opts -> opts { optPublisher = True } )) "Include book publisher if present. See below"@@ -103,5 +108,5 @@ , "" , "Magazines are kind of a sticky problem in that it's often desireable to have edition and/or date info in the filename. There's a lot of chaos out there with titling the epub editions of magazines. The solution in this software is to do some pattern matching on multiple fields in the magazine's metadata combined with custom naming code for specific magazines. This means that support for future magazines will likely have to be hand-coded into future versions of this utility. Modifying this just isn't very non-programmer friendly." , ""- , "Version 2.3.1 Dino Morelli <dino@ui3.info>"+ , "Version 2.3.2 Dino Morelli <dino@ui3.info>" ]
src/epubname.hs view
@@ -7,7 +7,7 @@ import Codec.Epub.Opf.Parse import Control.Monad import Control.Monad.Trans-import System.Directory ( renameFile )+import System.Directory ( doesFileExist, renameFile ) import System.Environment ( getArgs ) import System.Exit import System.IO ( BufferMode ( NoBuffering )@@ -51,7 +51,14 @@ pkg <- parseEpubOpf oldPath let md = opMeta pkg (fmtUsed, newPath) <- tryFormatting (oldPath, md)++ when (not $ optOverwrite opts) $ do+ fileExists <- liftIO $ doesFileExist newPath+ when fileExists $ throwError $ + printf "ERROR: File %s already exists!" newPath+ unless (optNoAction opts) $ liftIO $ renameFile oldPath newPath+ return (oldPath, newPath, fmtUsed, pkg) let (success, report) = either ((,) False)