diff options
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/Command.hs b/Command.hs index c6c1fe5c5..4f835a3ad 100644 --- a/Command.hs +++ b/Command.hs @@ -91,20 +91,12 @@ prepCommand Command { cmdseek = seek } params = do {- Runs a command through the start, perform and cleanup stages -} doCommand :: CommandStart -> CommandCleanup -doCommand start = do - s <- start - case s of - Nothing -> return True - Just perform -> do - p <- perform - case p of - Nothing -> do - showEndFail - return False - Just cleanup -> do - c <- cleanup - if c then showEndOk else showEndFail - return c +doCommand = start + where + start = stage $ maybe (return True) perform + perform = stage $ maybe (showEndFail >> return False) cleanup + cleanup = stage $ \r -> showEndResult r >> return r + stage a b = b >>= a notAnnexed :: FilePath -> Annex (Maybe a) -> Annex (Maybe a) notAnnexed file a = maybe a (const $ return Nothing) =<< Backend.lookupFile file |