32 lines
879 B
Haskell
32 lines
879 B
Haskell
module Main where
|
|
|
|
import CLI (Invocation(..), invoked)
|
|
import CSV (Row, parse)
|
|
import Data.Time (UTCTime(..), getCurrentTime)
|
|
import Event (Event)
|
|
import Medicine (Medicine, Pharmacy, pharmacy)
|
|
import System.Exit (exitFailure, exitSuccess)
|
|
import Timeline (State, currentState)
|
|
|
|
readCSV :: Row a => FilePath -> IO [a]
|
|
readCSV filePath = do
|
|
parsed <- parse filePath '\t' <$> readFile filePath
|
|
case parsed of
|
|
Left e -> (putStrLn $ show e) >> exitFailure
|
|
Right rows -> return rows
|
|
|
|
getCurrentState :: IO State
|
|
getCurrentState =
|
|
currentState
|
|
<$> (utctDay <$> getCurrentTime)
|
|
<*> (pharmacy <$> readCSV "medicine.csv")
|
|
<*> readCSV "timeline.csv"
|
|
|
|
main :: IO ()
|
|
main = do
|
|
invocation <- invoked
|
|
case invocation of
|
|
Inventory -> show <$> getCurrentState >>= putStrLn
|
|
Schedule -> putStrLn "schedule"
|
|
Version version -> putStrLn version >> exitSuccess
|