diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-09 12:23:45 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-09 12:23:45 -0400 |
commit | 3f5f28b48754bc91620a6354ca70afe4c61c9894 (patch) | |
tree | 6c71b52187f442ce619ffac7c672fc7f0b8f84ce /Command.hs | |
parent | d64132a43ae176e8a1353d5463c5387a93da9ad7 (diff) |
factor out a stopUnless
code melt for lunch
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Command.hs b/Command.hs index 86a83e30c..813a239cb 100644 --- a/Command.hs +++ b/Command.hs @@ -10,6 +10,7 @@ module Command ( noRepo, next, stop, + stopUnless, prepCommand, doCommand, whenAnnexed, @@ -49,6 +50,12 @@ next a = return $ Just a stop :: Annex (Maybe a) stop = return Nothing +{- Stops unless a condition is met. -} +stopUnless :: Annex Bool -> Annex (Maybe a) -> Annex (Maybe a) +stopUnless c a = do + ok <- c + if ok then a else stop + {- Prepares to run a command via the check and seek stages, returning a - list of actions to perform to run the command. -} prepCommand :: Command -> [String] -> Annex [CommandCleanup] |