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
|
{-# LANGUAGE RecordWildCards #-}
module Main (main) where
import System.Exit (exitSuccess, exitFailure)
import System.IO (hPutStrLn, stderr)
import Criterion.IO (readJSONReports)
import Criterion.Main (defaultConfig)
import Criterion.Monad (withConfig)
import Criterion.Report (report)
import Criterion.Types (Config(reportFile, template))
import Options
main :: IO ()
main = do
cmd <- parseCommandLine
case cmd of
Version -> putStrLn versionInfo >> exitSuccess
Report{..} -> do
let config = defaultConfig
{ reportFile = Just outputFile
, template = templateFile
}
res <- readJSONReports jsonFile
case res of
Left err -> do
hPutStrLn stderr $ "Error reading file: " ++ jsonFile
hPutStrLn stderr $ " " ++ show err
exitFailure
Right (_,_,rpts) -> withConfig config $ report rpts
|