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 System.Environment
|
||||||
|
|
||||||
import Options.Applicative
|
import Options.Applicative
|
||||||
|
import OptionsParser
|
||||||
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" )
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
@ -5,8 +5,8 @@ description: Please see README.md
|
|||||||
homepage: http://github.com/name/project
|
homepage: http://github.com/name/project
|
||||||
license: Apache
|
license: Apache
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Your name here
|
author: Filip Gralinski
|
||||||
maintainer: your.address@example.com
|
maintainer: filipg@amu.edu.pl
|
||||||
-- copyright:
|
-- copyright:
|
||||||
category: Web
|
category: Web
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
@ -16,6 +16,7 @@ cabal-version: >=1.10
|
|||||||
library
|
library
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
exposed-modules: GEval
|
exposed-modules: GEval
|
||||||
|
, OptionsParser
|
||||||
build-depends: base >= 4.7 && < 5
|
build-depends: base >= 4.7 && < 5
|
||||||
, cond
|
, cond
|
||||||
, conduit
|
, conduit
|
||||||
@ -23,6 +24,7 @@ library
|
|||||||
, conduit-extra
|
, conduit-extra
|
||||||
, directory
|
, directory
|
||||||
, filepath
|
, filepath
|
||||||
|
, optparse-applicative
|
||||||
, resourcet
|
, resourcet
|
||||||
, text
|
, text
|
||||||
default-language: Haskell2010
|
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