{-# 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")) )