summaryrefslogtreecommitdiff
path: root/Command.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-09 12:23:45 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-09 12:23:45 -0400
commit3f5f28b48754bc91620a6354ca70afe4c61c9894 (patch)
tree6c71b52187f442ce619ffac7c672fc7f0b8f84ce /Command.hs
parentd64132a43ae176e8a1353d5463c5387a93da9ad7 (diff)
factor out a stopUnless
code melt for lunch
Diffstat (limited to 'Command.hs')
-rw-r--r--Command.hs7
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]