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 Command
|
|
|
|
import Annex.Content
|
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2016-01-29 17:20:24 +00:00
|
|
|
cmd = noCommit $ noMessages $
|
2015-07-08 19:08:02 +00:00
|
|
|
command "contentlocation" SectionPlumbing
|
|
|
|
"looks up content for a key"
|
2015-07-12 00:43:45 +00:00
|
|
|
(paramRepeating paramKey)
|
|
|
|
(batchable run (pure ()))
|
2015-04-09 19:34:47 +00:00
|
|
|
|
2015-07-12 00:43:45 +00:00
|
|
|
run :: () -> String -> Annex Bool
|
|
|
|
run _ p = do
|
2019-01-14 17:17:47 +00:00
|
|
|
let k = fromMaybe (giveup "bad key") $ deserializeKey p
|
2015-07-12 00:43:45 +00:00
|
|
|
maybe (return False) (\f -> liftIO (putStrLn f) >> return True)
|
2015-04-09 19:34:47 +00:00
|
|
|
=<< inAnnex' (pure True) Nothing check k
|
|
|
|
where
|
|
|
|
check f = ifM (liftIO (doesFileExist f))
|
|
|
|
( return (Just f)
|
|
|
|
, return Nothing
|
|
|
|
)
|