aboutsummaryrefslogtreecommitdiff
path: root/src/CommandLineOptions.hs
blob: bb0ac8d0d7de3e93d80594cb11f3ca9095b04301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module CommandLineOptions
  ( parseOptions
  ) where

data Options = Options
  { materials :: [String]
  , ignoreMaterials :: [String]
  }

parseOptions :: [String] -> Options
parseOptions args =
  case splitWhere (== "--ignore") 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 _ [] = ([], [])