factor out a stopUnless

code melt for lunch
This commit is contained in:
Joey Hess 2011-12-09 12:23:45 -04:00
parent d64132a43a
commit 3f5f28b487
9 changed files with 69 additions and 107 deletions

View file

@ -21,18 +21,11 @@ seek :: [CommandSeek]
seek = [withKeys start]
start :: Key -> CommandStart
start key = do
present <- inAnnex key
if not present
then stop
else do
checkforced
showStart "dropkey" (show key)
next $ perform key
where
checkforced =
unlessM (Annex.getState Annex.force) $
error "dropkey can cause data loss; use --force if you're sure you want to do this"
start key = stopUnless (not <$> inAnnex key) $ do
unlessM (Annex.getState Annex.force) $
error "dropkey can cause data loss; use --force if you're sure you want to do this"
showStart "dropkey" (show key)
next $ perform key
perform :: Key -> CommandPerform
perform key = lockContent key $ do