add schedule command
Mostly because it gives me an excuse and a hook to document the schedule expression format.
This commit is contained in:
parent
a1040a38c5
commit
296e21b381
7 changed files with 109 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue