summaryrefslogtreecommitdiff
path: root/Command.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-30 20:04:15 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-31 12:15:38 -0400
commite09dd6f306b3f69718c77a03364ee9e51a51bb3b (patch)
treef9229dcd56a8d481f186b94f1ecc458e4e038555 /Command.hs
parent1530eac31294347a83c2a7973aa2c27ede9184f3 (diff)
cleanup
Diffstat (limited to 'Command.hs')
-rw-r--r--Command.hs21
1 files changed, 10 insertions, 11 deletions
diff --git a/Command.hs b/Command.hs
index 74b1ff21c..c11b90610 100644
--- a/Command.hs
+++ b/Command.hs
@@ -46,25 +46,24 @@ next a = return $ Just a
stop :: Annex (Maybe a)
stop = return Nothing
-{- Prepares a list of actions to run to perform a command, based on
- - the parameters passed to it. -}
-prepCommand :: Command -> [String] -> Annex [Annex Bool]
-prepCommand cmd ps = return . map doCommand =<< seekCommand cmd ps
-
-{- Runs a command through the seek stage. -}
-seekCommand :: Command -> [String] -> Annex [CommandStart]
-seekCommand Command { cmdseek = seek } ps = concat <$> mapM (\s -> s ps) seek
+{- 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]
+prepCommand Command { cmdseek = seek, cmdcheck = c } params = do
+ sequence_ $ map runCheck c
+ map doCommand . concat <$> mapM (\s -> s params) seek
{- Runs a command through the start, perform and cleanup stages -}
doCommand :: CommandStart -> CommandCleanup
doCommand = start
where
- start = stage $ maybe success perform
+ start = stage $ maybe skip perform
perform = stage $ maybe failure cleanup
- cleanup = stage $ \r -> showEndResult r >> return r
+ cleanup = stage $ status
stage = (=<<)
- success = return True
+ skip = return True
failure = showEndFail >> return False
+ status r = showEndResult r >> return r
notAnnexed :: FilePath -> Annex (Maybe a) -> Annex (Maybe a)
notAnnexed file a = maybe a (const $ return Nothing) =<< Backend.lookupFile file