move option parsing to lib
This commit is contained in:
parent
866917fc3f
commit
228b7b0606
53
app/Main.hs
53
app/Main.hs
@ -4,58 +4,7 @@ import GEval
|
||||
import System.Environment
|
||||
|
||||
import Options.Applicative
|
||||
|
||||
fullOptionsParser = info (helper <*> optionsParser)
|
||||
(fullDesc
|
||||
<> progDesc "Run evaluation for tests in Gonito platform"
|
||||
<> header "geval - stand-alone evaluation tool for tests in Gonito platform")
|
||||
|
||||
optionsParser :: Parser GEvalOptions
|
||||
optionsParser = GEvalOptions
|
||||
<$> switch
|
||||
( long "init"
|
||||
<> help "Init a sample Gonito challange rather than run an evaluation" )
|
||||
<*> specParser
|
||||
|
||||
specParser :: Parser GEvalSpecification
|
||||
specParser = GEvalSpecification
|
||||
<$> strOption
|
||||
( long "out-directory"
|
||||
<> value defaultOutDirectory
|
||||
<> showDefault
|
||||
<> metavar "OUT-DIRECTORY"
|
||||
<> help "Directory with test results to be evaluated" )
|
||||
<*> optional (strOption
|
||||
( long "expected-directory"
|
||||
<> metavar "EXPECTED-DIRECTORY"
|
||||
<> help "Directory with expected test results (if not specified the same as OUT-DIRECTORY)" ))
|
||||
<*> strOption
|
||||
( long "test-name"
|
||||
<> value defaultTestName
|
||||
<> showDefault
|
||||
<> metavar "NAME"
|
||||
<> help "Test name (i.e. subdirectory with results or expected results)" )
|
||||
<*> strOption
|
||||
( long "out-file"
|
||||
<> value defaultOutFile
|
||||
<> showDefault
|
||||
<> metavar "OUT"
|
||||
<> help "The name of the file to be evaluated" )
|
||||
<*> strOption
|
||||
( long "expected-file"
|
||||
<> value defaultExpectedFile
|
||||
<> showDefault
|
||||
<> metavar "EXPECTED"
|
||||
<> help "The name of the file with expected results" )
|
||||
<*> metricReader
|
||||
|
||||
metricReader :: Parser Metric
|
||||
metricReader = option auto
|
||||
( long "metric"
|
||||
<> value defaultMetric
|
||||
<> showDefault
|
||||
<> metavar "METRIC"
|
||||
<> help "Metric to be used" )
|
||||
import OptionsParser
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
|
@ -5,8 +5,8 @@ description: Please see README.md
|
||||
homepage: http://github.com/name/project
|
||||
license: Apache
|
||||
license-file: LICENSE
|
||||
author: Your name here
|
||||
maintainer: your.address@example.com
|
||||
author: Filip Gralinski
|
||||
maintainer: filipg@amu.edu.pl
|
||||
-- copyright:
|
||||
category: Web
|
||||
build-type: Simple
|
||||
@ -16,6 +16,7 @@ cabal-version: >=1.10
|
||||
library
|
||||
hs-source-dirs: src
|
||||
exposed-modules: GEval
|
||||
, OptionsParser
|
||||
build-depends: base >= 4.7 && < 5
|
||||
, cond
|
||||
, conduit
|
||||
@ -23,6 +24,7 @@ library
|
||||
, conduit-extra
|
||||
, directory
|
||||
, filepath
|
||||
, optparse-applicative
|
||||
, resourcet
|
||||
, text
|
||||
default-language: Haskell2010
|
||||
|
57
src/OptionsParser.hs
Normal file
57
src/OptionsParser.hs
Normal file
@ -0,0 +1,57 @@
|
||||
module OptionsParser
|
||||
(fullOptionsParser) where
|
||||
|
||||
import Options.Applicative
|
||||
import GEval
|
||||
|
||||
fullOptionsParser = info (helper <*> optionsParser)
|
||||
(fullDesc
|
||||
<> progDesc "Run evaluation for tests in Gonito platform"
|
||||
<> header "geval - stand-alone evaluation tool for tests in Gonito platform")
|
||||
|
||||
optionsParser :: Parser GEvalOptions
|
||||
optionsParser = GEvalOptions
|
||||
<$> switch
|
||||
( long "init"
|
||||
<> help "Init a sample Gonito challange rather than run an evaluation" )
|
||||
<*> specParser
|
||||
|
||||
specParser :: Parser GEvalSpecification
|
||||
specParser = GEvalSpecification
|
||||
<$> strOption
|
||||
( long "out-directory"
|
||||
<> value defaultOutDirectory
|
||||
<> showDefault
|
||||
<> metavar "OUT-DIRECTORY"
|
||||
<> help "Directory with test results to be evaluated" )
|
||||
<*> optional (strOption
|
||||
( long "expected-directory"
|
||||
<> metavar "EXPECTED-DIRECTORY"
|
||||
<> help "Directory with expected test results (if not specified the same as OUT-DIRECTORY)" ))
|
||||
<*> strOption
|
||||
( long "test-name"
|
||||
<> value defaultTestName
|
||||
<> showDefault
|
||||
<> metavar "NAME"
|
||||
<> help "Test name (i.e. subdirectory with results or expected results)" )
|
||||
<*> strOption
|
||||
( long "out-file"
|
||||
<> value defaultOutFile
|
||||
<> showDefault
|
||||
<> metavar "OUT"
|
||||
<> help "The name of the file to be evaluated" )
|
||||
<*> strOption
|
||||
( long "expected-file"
|
||||
<> value defaultExpectedFile
|
||||
<> showDefault
|
||||
<> metavar "EXPECTED"
|
||||
<> help "The name of the file with expected results" )
|
||||
<*> metricReader
|
||||
|
||||
metricReader :: Parser Metric
|
||||
metricReader = option auto
|
||||
( long "metric"
|
||||
<> value defaultMetric
|
||||
<> showDefault
|
||||
<> metavar "METRIC"
|
||||
<> help "Metric to be used" )
|
Loading…
Reference in New Issue
Block a user