summaryrefslogtreecommitdiff
path: root/Command/Whereis.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2014-01-26 14:26:32 -0400
committerJoey Hess <joey@kitenet.net>2014-01-26 14:26:32 -0400
commit85398d068eadc58b6a74b73c62bc25955443f9ec (patch)
treefb90ac4afdc18b656a8537ff1e00cc6dfb1bfff8 /Command/Whereis.hs
parente72aafac7ae43a60ee31fc7c25d864e04797027f (diff)
whereis: Support --all.
Diffstat (limited to 'Command/Whereis.hs')
-rw-r--r--Command/Whereis.hs18
1 files changed, 14 insertions, 4 deletions
diff --git a/Command/Whereis.hs b/Command/Whereis.hs
index 4030cf2f8e..0083f8c5c7 100644
--- a/Command/Whereis.hs
+++ b/Command/Whereis.hs
@@ -14,20 +14,30 @@ import Command
import Remote
import Logs.Trust
import GitAnnex.Options
+import Types.Key
def :: [Command]
-def = [noCommit $ withOptions [jsonOption] $
+def = [noCommit $ withOptions (jsonOption : keyOptions) $
command "whereis" paramPaths seek SectionQuery
"lists repositories that have file content"]
seek :: CommandSeek
seek ps = do
m <- remoteMap id
- withFilesInGit (whenAnnexed $ start m) ps
+ withKeyOptions
+ (startKeys m)
+ (withFilesInGit $ whenAnnexed $ start m)
+ ps
start :: M.Map UUID Remote -> FilePath -> (Key, Backend) -> CommandStart
-start remotemap file (key, _) = do
- showStart "whereis" file
+start remotemap file (key, _) = start' remotemap key (Just file)
+
+startKeys :: M.Map UUID Remote -> Key -> CommandStart
+startKeys remotemap key = start' remotemap key Nothing
+
+start' :: M.Map UUID Remote -> Key -> AssociatedFile -> CommandStart
+start' remotemap key afile = do
+ showStart "whereis" (fromMaybe (key2file key) afile)
next $ perform remotemap key
perform :: M.Map UUID Remote -> Key -> CommandPerform