{-- | Module : Options Description : Plan execution options Copyright : (c) Mihai Giurgeanu, 2017 License : GPL-3 Maintainer : mihai.giurgeanu@gmail.com Stability : experimental Portability : Portable --} module Options where import TransferPlan (TransferPlan) import Data.Yaml.Aeson (decodeFileEither, prettyPrintParseException, ParseException) import System.IO (hPutStrLn, stderr) import System.Environment (getProgName) readPlan :: FilePath -> IO TransferPlan readPlan planFile = let failParse :: ParseException -> IO a failParse exception = do hPutStrLn stderr $ "Error parsing the transfer plan file (" ++ planFile ++ ")" fail $ prettyPrintParseException exception in do thePlan <- decodeFileEither planFile either failParse return thePlan data Options = Options { option_Plan :: TransferPlan, option_Threads :: Int, option_Count :: Int, option_Drop :: Int }