Newer
Older
import Data.Semigroup ((<>))
import Options.Applicative
import API (Mode (..), ParseMode (..), compareSpec)
-- | Command-line options.
data Options = Options
{ sourceA :: String
, sourceB :: String
, methodA :: String
, methodB :: String
Joris ten Tusscher
committed
, mode :: Mode
}
-- | Parsing of command-line options.
parseOptions :: Parser Options
parseOptions = Options
<$> strOption
( long "srcA"
<> showDefault
<> value "examples/javawlp_edsl/src/nl/uu/javawlp_edsl/Main.java"
<> metavar "STRING"
<> help "Java source file for A"
)
<*> strOption
( long "srcB"
<> showDefault
<> value "examples/javawlp_edsl/src/nl/uu/javawlp_edsl/Main.java"
<> metavar "STRING"
<> metavar "STRING"
<> help "First method"
)
<*> strOption
( short 'b'
<> metavar "STRING"
<> help "Second method"
)
<*> switch
( short 'w'
<> long "runServer"
<> help "Run server"
)
<*> option auto
( short 'p'
<> long "port"
<> metavar "INT"
<> showDefault
<> value 8888
<> help "Listening port"
)
Joris ten Tusscher
committed
<*> (toMode <$> switch
( short 'd'
<> long "debugMode"
<> help "Run in debug mode (instead of release)"
))
toMode :: Bool -> Mode
toMode False = Release
toMode True = Debug
withInfo :: Parser a -> String -> ParserInfo a
withInfo opts desc = info (helper <*> opts) $ progDesc desc
-- | Main.
main :: IO ()
main = runMain =<< execParser (parseOptions `withInfo` "Java WLP")
Joris ten Tusscher
committed
runMain (Options srcA srcB methA methB serverFlag portNo runMode) =
when (methA == "_default_") $ fail "No files given."
Joris ten Tusscher
committed
response <- compareSpec runMode File (srcA, methA) (srcB, methB)