blob: 5b0bcbbd266c8eb56d2c5a9ee0fea8e8266d0cd4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
{- git-annex command
-
- Copyright 2010 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Command.Whereis where
import Control.Monad.State (liftIO)
import qualified Annex
import LocationLog
import Command
import Messages
import UUID
import Types
command :: [Command]
command = [Command "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
return $ Just $ perform key
perform :: Key -> CommandPerform
perform key = do
g <- Annex.gitRepo
uuids <- liftIO $ keyLocations g key
let num = length uuids
showNote $ show num ++ " " ++ copiesplural num
if null $ uuids
then return Nothing
else do
pp <- prettyPrintUUIDs uuids
showLongNote $ pp
showProgress
return $ Just $ return True
where
copiesplural 1 = "copy"
copiesplural _ = "copies"
|