aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2015-03-31 18:29:05 +0900
committerSean Whitton <spwhitton@spwhitton.name>2015-03-31 18:29:05 +0900
commit7177f951bd942ca7710b669e4b3f43e700d4f2fa (patch)
tree7bf244075e8358609e3df5f5c2cd9d4b80a792b8
parent82dee866a4af3db1943c26ead9b9310b2dc5ab4b (diff)
downloadsrem-7177f951bd942ca7710b669e4b3f43e700d4f2fa.tar.gz
fill out more of Main.hs
-rw-r--r--src/Main.hs31
-rw-r--r--src/Utility/Notify.hs6
2 files changed, 29 insertions, 8 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 446572f..fe11389 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -22,21 +22,34 @@
-}
import Control.Applicative ((<$>), (<*>))
+import Control.Monad (mapM_)
+import Data.List (intercalate)
import Data.Time.Calendar
import Data.Time.LocalTime
import System.Environment (getArgs)
+import Text.Regex.Posix ((=~))
import Types.Reminder
import Utility.EventCache
+import Utility.Notify
-doCron :: IO ()
-doCron = do
- rems <- (++) <$> readEmacsEventCache <*> readManualEventCache
+doCron :: IO ()
+doCron = do
+ rems <- (++) <$> readEmacsEventCache <*> readManualEventCache
(h, m, _) <- localHMD
- let nowRems = filter undefined rems
- undefined
+ let nowRemsFilter r = getReminderHour r == h
+ && getReminderMinute r == m
+ nowRems = filter nowRemsFilter rems
+ mapM_ sendNotification nowRems
-cmdLineReminder :: [String] -> Maybe Reminder
-cmdLineReminder args = undefined
+cmdLineReminder :: [String] -> Maybe Reminder
+cmdLineReminder [] = Nothing
+cmdLineReminder [_] = Nothing
+cmdLineReminder (exp:textParts) = do
+ undefined
+ where
+ text = intercalate " " textParts
+ relativeRegExp = "[0-9]+[mh]"
+ absoluteRegExp = "[0-9]{1,2}(:[0-9][0-9])?(am|pm)?"
appendUserReminder :: Reminder -> IO ()
appendUserReminder r = do
@@ -58,7 +71,9 @@ appendUserReminder r = do
-- appointment in Emacs Org-mode should be used instead of srem's
-- manual reminder input.
let dummyRem = makeReminder' h m (getReminderText r)
- undefined
+ if maybe False (r <=) dummyRem
+ then appendManualEventCache r (addDays 1 d)
+ else appendManualEventCache r d
main = do
args <- getArgs
diff --git a/src/Utility/Notify.hs b/src/Utility/Notify.hs
new file mode 100644
index 0000000..3912314
--- /dev/null
+++ b/src/Utility/Notify.hs
@@ -0,0 +1,6 @@
+module Utility.Notify (sendNotification) where
+
+import Types.Reminder
+
+sendNotification :: Reminder -> IO ()
+sendNotification r = undefined