module Trace.Hpc.Codecov.Main (defaultMain) where
import Control.Exception (throwIO)
import System.Environment (getArgs)
import Trace.Hpc.Codecov.Exception
import Trace.Hpc.Codecov.Options
import Trace.Hpc.Codecov.Report
defaultMain :: IO ()
defaultMain :: IO ()
defaultMain = IO () -> IO ()
forall a. IO a -> IO a
withBriefUsageOnError (IO [String]
getArgs IO [String] -> ([String] -> IO ()) -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [String] -> IO ()
go)
where
go :: [String] -> IO ()
go [String]
args =
case [String] -> Either [String] Options
parseOptions [String]
args of
Right Options
opts | Options -> Bool
optShowHelp Options
opts -> IO ()
printHelp
| Options -> Bool
optShowVersion Options
opts -> IO ()
printVersion
| Options -> Bool
optShowNumeric Options
opts -> String -> IO ()
putStrLn String
versionString
| Bool
otherwise -> Options -> IO Report
opt2rpt Options
opts IO Report -> (Report -> IO ()) -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Report -> IO ()
genReport
Left [String]
errs -> HpcCodecovError -> IO ()
forall e a. Exception e => e -> IO a
throwIO ([String] -> HpcCodecovError
InvalidArgs [String]
errs)