2011-03-05 21:23:55 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Whereis where
|
|
|
|
|
|
|
|
import LocationLog
|
|
|
|
import Command
|
|
|
|
import Messages
|
2011-07-01 19:24:07 +00:00
|
|
|
import Remote
|
2011-03-05 21:23:55 +00:00
|
|
|
import Types
|
|
|
|
|
|
|
|
command :: [Command]
|
2011-03-19 22:58:49 +00:00
|
|
|
command = [repoCommand "whereis" (paramOptional $ paramRepeating paramPath) seek
|
2011-03-05 21:23:55 +00:00
|
|
|
"lists repositories that have file content"]
|
|
|
|
|
|
|
|
seek :: [CommandSeek]
|
|
|
|
seek = [withFilesInGit start]
|
|
|
|
|
|
|
|
start :: CommandStartString
|
|
|
|
start file = isAnnexed file $ \(key, _) -> do
|
|
|
|
showStart "whereis" file
|
2011-05-15 06:02:46 +00:00
|
|
|
next $ perform key
|
2011-03-05 21:23:55 +00:00
|
|
|
|
|
|
|
perform :: Key -> CommandPerform
|
|
|
|
perform key = do
|
2011-06-22 20:13:43 +00:00
|
|
|
uuids <- keyLocations key
|
2011-03-05 21:41:36 +00:00
|
|
|
let num = length uuids
|
|
|
|
showNote $ show num ++ " " ++ copiesplural num
|
2011-07-15 16:47:14 +00:00
|
|
|
if null uuids
|
2011-05-15 06:02:46 +00:00
|
|
|
then stop
|
2011-03-05 21:41:36 +00:00
|
|
|
else do
|
2011-09-01 20:02:01 +00:00
|
|
|
pp <- prettyPrintUUIDs "whereis" uuids
|
2011-07-15 16:47:14 +00:00
|
|
|
showLongNote pp
|
2011-07-19 18:07:23 +00:00
|
|
|
showOutput
|
2011-05-15 06:02:46 +00:00
|
|
|
next $ return True
|
2011-03-05 21:41:36 +00:00
|
|
|
where
|
|
|
|
copiesplural 1 = "copy"
|
|
|
|
copiesplural _ = "copies"
|