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