introduce special command

This commit is contained in:
Filip Gralinski 2018-01-09 07:58:18 +01:00 committed by Filip Gralinski
parent a2814f2d12
commit 11b43b3a2a
2 changed files with 13 additions and 10 deletions

View File

@ -14,6 +14,7 @@ module GEval.Core
MetricOrdering(..),
getMetricOrdering,
MetricValue,
GEvalSpecialCommand(..),
GEvalSpecification(..),
GEvalOptions(..),
GEvalException(..),
@ -144,8 +145,10 @@ getExpectedDirectory :: GEvalSpecification -> FilePath
getExpectedDirectory spec = fromMaybe outDirectory $ gesExpectedDirectory spec
where outDirectory = gesOutDirectory spec
data GEvalSpecialCommand = Init
data GEvalOptions = GEvalOptions
{ geoInit :: Bool,
{ geoSpecialCommand :: Maybe GEvalSpecialCommand,
geoPrecision :: Maybe Int,
geoSpec :: GEvalSpecification }

View File

@ -26,9 +26,9 @@ fullOptionsParser = info (helper <*> optionsParser)
optionsParser :: Parser GEvalOptions
optionsParser = GEvalOptions
<$> switch
( long "init"
<> help "Init a sample Gonito challenge rather than run an evaluation" )
<$> optional (flag' Init
( long "init"
<> help "Init a sample Gonito challenge rather than run an evaluation" ))
<*> optional precisionArgParser
<*> specParser
@ -127,15 +127,15 @@ attemptToReadOptsFromConfigFile args opts = do
runGEval'' :: GEvalOptions -> IO (Maybe MetricValue)
runGEval'' opts = runGEval''' (geoInit opts) (geoSpec opts)
runGEval'' opts = runGEval''' (geoSpecialCommand opts) (geoSpec opts)
runGEval''' :: Bool -> GEvalSpecification -> IO (Maybe MetricValue)
runGEval''' True spec = do
initChallenge spec
return Nothing
runGEval''' False spec = do
runGEval''' :: Maybe GEvalSpecialCommand -> GEvalSpecification -> IO (Maybe MetricValue)
runGEval''' Nothing spec = do
val <- geval spec
return $ Just val
runGEval''' (Just Init) spec = do
initChallenge spec
return Nothing
initChallenge :: GEvalSpecification -> IO ()
initChallenge spec = case gesExpectedDirectory spec of