2015-08-17 23:32:00 +02:00
|
|
|
module Main where
|
|
|
|
|
2015-08-23 08:14:47 +02:00
|
|
|
import GEval.Core
|
|
|
|
import GEval.OptionsParser
|
2015-08-17 23:32:00 +02:00
|
|
|
|
2015-08-23 08:14:47 +02:00
|
|
|
import System.Environment
|
2015-08-22 00:00:46 +02:00
|
|
|
import Options.Applicative
|
|
|
|
|
2015-09-12 15:36:50 +02:00
|
|
|
import Text.Printf
|
|
|
|
|
2015-08-17 23:32:00 +02:00
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2015-08-22 20:28:10 +02:00
|
|
|
args <- getArgs
|
2015-09-12 15:36:50 +02:00
|
|
|
result <- runGEvalGetOptions args
|
2015-08-22 20:28:10 +02:00
|
|
|
case result of
|
|
|
|
Left parseResult -> handleParseResult parseResult >> return ()
|
2015-09-12 15:36:50 +02:00
|
|
|
Right (opts, Just result) -> showTheResult opts result
|
|
|
|
Right (_, Nothing) -> return ()
|
|
|
|
|
|
|
|
showTheResult :: GEvalOptions -> MetricValue -> IO ()
|
2018-01-25 09:11:04 +01:00
|
|
|
showTheResult opts val = putStrLn $ formatTheResult (gesPrecision $ geoSpec opts) val
|
2015-09-12 15:36:50 +02:00
|
|
|
|
|
|
|
formatTheResult :: Maybe Int -> MetricValue -> String
|
|
|
|
formatTheResult Nothing = show
|
|
|
|
formatTheResult (Just prec) = printf "%0.*f" prec
|