diff options
author | Joey Hess <joey@kitenet.net> | 2013-10-13 15:40:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-10-13 15:40:38 -0400 |
commit | d6bf4460d8b7ff91ba553958240054ca8a2a91d6 (patch) | |
tree | bc23043851e98c771a3b451456a0103332b20444 /Types | |
parent | f0cf034faa674921dae63d7a54270861bbe86e29 (diff) |
add schedule command
Mostly because it gives me an excuse and a hook to document the schedule
expression format.
Diffstat (limited to 'Types')
-rw-r--r-- | Types/ScheduledActivity.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Types/ScheduledActivity.hs b/Types/ScheduledActivity.hs index e29050d8e..386f42333 100644 --- a/Types/ScheduledActivity.hs +++ b/Types/ScheduledActivity.hs @@ -12,6 +12,8 @@ import Utility.Scheduled import Utility.HumanTime import Types.UUID +import Data.Either + data ScheduledActivity = ScheduledSelfFsck Schedule Duration | ScheduledRemoteFsck UUID Schedule Duration @@ -48,3 +50,14 @@ parseScheduledActivity s = case words s of qualified (Left e) = Left $ e ++ " in \"" ++ s ++ "\"" qualified v = v getduration d = maybe (Left $ "failed to parse duration \""++d++"\"") Right (parseDuration d) + +fromScheduledActivities :: [ScheduledActivity] -> String +fromScheduledActivities = intercalate "; " . map fromScheduledActivity + +parseScheduledActivities :: String -> Either String [ScheduledActivity] +parseScheduledActivities s + | null bad = Right good + | otherwise = Left $ intercalate "; " bad + where + (bad, good) = partitionEithers $ + map parseScheduledActivity $ split "; " s |