Command line utilities for working with epub files (Haskell)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| -- License: BSD3 (see LICENSE)
-- Author: Dino Morelli <dino@ui3.info>
module Main
where
import Control.Monad.Except
import System.Exit
import Test.HUnit ( Counts (..), Test (..), runTestTT )
import EpubTools.EpubName.Format.Format
import EpubTools.EpubName.Main
import EpubTools.EpubName.Opts
import EpubTools.Test.EpubName.Format
import EpubTools.Test.EpubName.PubYear
main :: IO ()
main = do
dos <- defaultOptions
let testOpts = dos -- Can use this to adjust the options with dos { ... }
ir <- runExceptT $ initialize testOpts
either (exitWith) (runTests testOpts) ir
runTests :: Options -> [Formatter] -> IO ()
runTests opts fs = do
counts <- runTestTT $ tests opts fs
exit $ testsPassed counts
exit :: Bool -> IO ()
exit True = exitWith ExitSuccess
exit False = exitWith $ ExitFailure 1
testsPassed :: Counts -> Bool
testsPassed (Counts _ _ e f) = (e == 0) && (f == 0)
tests :: Options -> [Formatter] -> Test
tests opts fs = TestList
[ formatTests opts fs
, pubYearTests
]
|