introduce special command
This commit is contained in:
parent
a2814f2d12
commit
11b43b3a2a
@ -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 }
|
||||
|
||||
|
@ -26,9 +26,9 @@ fullOptionsParser = info (helper <*> optionsParser)
|
||||
|
||||
optionsParser :: Parser GEvalOptions
|
||||
optionsParser = GEvalOptions
|
||||
<$> switch
|
||||
<$> optional (flag' Init
|
||||
( long "init"
|
||||
<> help "Init a sample Gonito challenge rather than run an evaluation" )
|
||||
<> 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
|
||||
|
Loading…
Reference in New Issue
Block a user