summaryrefslogtreecommitdiff
path: root/Command/Whereis.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-05 17:23:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-05 17:23:55 -0400
commit0de3005c648400e67ce4bfe88ac7999e56e3b56e (patch)
tree7afefc6d0079611928706fee9e7a59012ce774d6 /Command/Whereis.hs
parent41d5c4acf6810966bdef25e2fc7a4cfb78b6f972 (diff)
whereis: New subcommand to show where a file's content has gotten to.
Diffstat (limited to 'Command/Whereis.hs')
-rw-r--r--Command/Whereis.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
new file mode 100644
index 000000000..de5192385
--- /dev/null
+++ b/Command/Whereis.hs
@@ -0,0 +1,41 @@
+{- 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 Content
+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
+ pp <- prettyPrintUUIDs uuids
+ showLongNote $ pp
+ showProgress
+ if null $ uuids
+ then return Nothing
+ else return $ Just $ return True