move main run procedure to OptionsParser
This commit is contained in:
parent
228b7b0606
commit
4efd99bef9
@ -8,6 +8,9 @@ import OptionsParser
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
opts <- execParser fullOptionsParser
|
||||
result <- geval $ geoSpec opts
|
||||
print $ result
|
||||
args <- getArgs
|
||||
result <- runGEval args
|
||||
case result of
|
||||
Left parseResult -> handleParseResult parseResult >> return ()
|
||||
Right (Just result) -> print $ result
|
||||
Right Nothing -> return ()
|
||||
|
@ -1,5 +1,6 @@
|
||||
module OptionsParser
|
||||
(fullOptionsParser) where
|
||||
(fullOptionsParser,
|
||||
runGEval) where
|
||||
|
||||
import Options.Applicative
|
||||
import GEval
|
||||
@ -55,3 +56,12 @@ metricReader = option auto
|
||||
<> showDefault
|
||||
<> metavar "METRIC"
|
||||
<> help "Metric to be used" )
|
||||
|
||||
runGEval :: [String] -> IO (Either (ParserResult GEvalOptions) (Maybe Double))
|
||||
runGEval args =
|
||||
case parserResult of
|
||||
Success opts -> do
|
||||
val <- geval $ geoSpec opts
|
||||
return $ Right $ Just val
|
||||
otherwise -> return $ Left parserResult
|
||||
where parserResult = execParserPure (prefs idm) fullOptionsParser args
|
||||
|
Loading…
Reference in New Issue
Block a user