move main run procedure to OptionsParser
This commit is contained in:
parent
228b7b0606
commit
4efd99bef9
@ -8,6 +8,9 @@ import OptionsParser
|
|||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
opts <- execParser fullOptionsParser
|
args <- getArgs
|
||||||
result <- geval $ geoSpec opts
|
result <- runGEval args
|
||||||
print $ result
|
case result of
|
||||||
|
Left parseResult -> handleParseResult parseResult >> return ()
|
||||||
|
Right (Just result) -> print $ result
|
||||||
|
Right Nothing -> return ()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
module OptionsParser
|
module OptionsParser
|
||||||
(fullOptionsParser) where
|
(fullOptionsParser,
|
||||||
|
runGEval) where
|
||||||
|
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
import GEval
|
import GEval
|
||||||
@ -55,3 +56,12 @@ metricReader = option auto
|
|||||||
<> showDefault
|
<> showDefault
|
||||||
<> metavar "METRIC"
|
<> metavar "METRIC"
|
||||||
<> help "Metric to be used" )
|
<> 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