{-# LANGUAGE OverloadedStrings #-} module CommandLineOptions ( Options(..) , parseOptions ) where import Data.Text (Text) data Options = Options { materials :: [Text] , ignoreMaterials :: [Text] } deriving (Eq, Show) parseOptions :: [Text] -> Options parseOptions args = case splitWhere (== "--without") args of (materials, ignoredMaterials) -> Options materials ignoredMaterials splitWhere :: (a -> Bool) -> [a] -> ([a], [a]) splitWhere match (x:xs) | match x = ([], xs) splitWhere match (x:xs) = case (splitWhere match xs) of (ys, zs) -> (x:ys, zs) splitWhere _ [] = ([], [])