diff --git a/src/GEval/Core.hs b/src/GEval/Core.hs index 3b85042..132c7fc 100644 --- a/src/GEval/Core.hs +++ b/src/GEval/Core.hs @@ -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 } diff --git a/src/GEval/OptionsParser.hs b/src/GEval/OptionsParser.hs index 51bf9cd..fdf2f6a 100644 --- a/src/GEval/OptionsParser.hs +++ b/src/GEval/OptionsParser.hs @@ -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