git-annex/Command/Whereis.hs
Joey Hess d3f0106f2e move LocationLog into Annex monad from IO
It will need to run in Annex so it can use Branch
2011-06-22 14:27:50 -04:00

44 lines
945 B
Haskell

{- git-annex command
-
- Copyright 2010 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Whereis where
import qualified Annex
import LocationLog
import Command
import Messages
import UUID
import Types
command :: [Command]
command = [repoCommand "whereis" (paramOptional $ paramRepeating paramPath) seek
"lists repositories that have file content"]
seek :: [CommandSeek]
seek = [withFilesInGit start]
start :: CommandStartString
start file = isAnnexed file $ \(key, _) -> do
showStart "whereis" file
next $ perform key
perform :: Key -> CommandPerform
perform key = do
g <- Annex.gitRepo
uuids <- keyLocations g key
let num = length uuids
showNote $ show num ++ " " ++ copiesplural num
if null $ uuids
then stop
else do
pp <- prettyPrintUUIDs uuids
showLongNote $ pp
showProgress
next $ return True
where
copiesplural 1 = "copy"
copiesplural _ = "copies"