diff options
Diffstat (limited to 'Command.hs')
-rw-r--r-- | Command.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Command.hs b/Command.hs index c436c5b62..083be37f2 100644 --- a/Command.hs +++ b/Command.hs @@ -15,8 +15,8 @@ module Command ( stop, prepCommand, doCommand, + whenAnnexed, notAnnexed, - isAnnexed, notBareRepo, isBareRepo, autoCopies @@ -65,12 +65,14 @@ doCommand = start failure = showEndFail >> return False status r = showEndResult r >> return r +{- Modifies an action to only act on files that are already annexed, + - and passes the key and backend on to it. -} +whenAnnexed :: (FilePath -> (Key, Backend Annex) -> Annex (Maybe a)) -> FilePath -> Annex (Maybe a) +whenAnnexed a file = maybe (return Nothing) (a file) =<< Backend.lookupFile file + notAnnexed :: FilePath -> Annex (Maybe a) -> Annex (Maybe a) notAnnexed file a = maybe a (const $ return Nothing) =<< Backend.lookupFile file -isAnnexed :: FilePath -> ((Key, Backend Annex) -> Annex (Maybe a)) -> Annex (Maybe a) -isAnnexed file a = maybe (return Nothing) a =<< Backend.lookupFile file - notBareRepo :: Annex a -> Annex a notBareRepo a = do whenM isBareRepo $ |