1
Fork 0
mirror of https://git.cs.ou.nl/joshua.moerman/mealy-decompose.git synced 2025-04-30 02:07:44 +02:00
mealy-decompose/hs/app/Main.hs
2025-04-16 13:59:41 +02:00

51 lines
1.6 KiB
Haskell

{-# OPTIONS_GHC -Wno-missing-signatures #-}
module Main where
import CommonOptions
import DecomposeInput
import DecomposeOutput
import RandomGen
import Options.Applicative
import System.Directory
main = do
-- parse command and options
let opts = info optionsParser (fullDesc <> header "Tool(s) to decompose a finite state machine into separate components.")
Options{..} <- execParser opts
-- setup some logging facilities
createDirectoryIfMissing True (logDirectory commonOptions)
createDirectoryIfMissing True (resultsDirectory commonOptions)
-- dispatch to actual functionality, based on the command provided
case optCommand of
DecomposeOutput options -> mainDecomposeOutput options commonOptions
DecomposeInput options -> mainDecomposeInput options commonOptions
RandomGen options -> mainRandomGen options
data Options = Options
{ optCommand :: Command
, commonOptions :: CommonOptions
}
deriving Show
optionsParser =
Options
<$> commandParser
<*> commonOptionsParser
<**> helper
data Command
= DecomposeOutput DecomposeOutputOptions
| DecomposeInput DecomposeInputOptions
| RandomGen RandomGenOptions
deriving Show
commandParser =
subparser
( command "decompose-output" (info (DecomposeOutput <$> decomposeOutputOptionsParser) (progDesc "decompose based on output"))
<> command "decompose-input" (info (DecomposeInput <$> decomposeInputOptionsParser) (progDesc "decompose based on independent inputs"))
<> command "random-gen" (info (RandomGen <$> randomGenOptionsParser) (progDesc "generate random parallel compositions"))
)