2015-04-09 19:34:47 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2015 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.ContentLocation where
|
|
|
|
|
|
|
|
import Common.Annex
|
|
|
|
import Command
|
2015-05-06 17:44:53 +00:00
|
|
|
import CmdLine.Batch
|
2015-04-09 19:34:47 +00:00
|
|
|
import Annex.Content
|
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
|
|
|
cmd = withOptions [batchOption] $ noCommit $ noMessages $
|
2015-04-09 19:34:47 +00:00
|
|
|
command "contentlocation" (paramRepeating paramKey) seek
|
2015-07-08 16:33:27 +00:00
|
|
|
SectionPlumbing "looks up content for a key"
|
2015-04-09 19:34:47 +00:00
|
|
|
|
|
|
|
seek :: CommandSeek
|
2015-05-06 17:44:53 +00:00
|
|
|
seek = batchable withKeys start
|
2015-04-09 19:34:47 +00:00
|
|
|
|
2015-05-06 17:44:53 +00:00
|
|
|
start :: Batchable Key
|
|
|
|
start batchmode k = do
|
|
|
|
maybe (batchBadInput batchmode) (liftIO . putStrLn)
|
2015-04-09 19:34:47 +00:00
|
|
|
=<< inAnnex' (pure True) Nothing check k
|
|
|
|
stop
|
|
|
|
where
|
|
|
|
check f = ifM (liftIO (doesFileExist f))
|
|
|
|
( return (Just f)
|
|
|
|
, return Nothing
|
|
|
|
)
|