2015-03-20 15:22:27 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2015 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.ReadPresentKey where
|
|
|
|
|
|
|
|
import Common.Annex
|
|
|
|
import Command
|
|
|
|
import Logs.Location
|
|
|
|
import Types.Key
|
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2015-07-08 19:08:02 +00:00
|
|
|
cmd = noCommit $
|
|
|
|
command "readpresentkey" SectionPlumbing
|
|
|
|
"read records of where key is present"
|
|
|
|
(paramPair paramKey paramUUID)
|
|
|
|
(withParams seek)
|
2015-03-20 15:22:27 +00:00
|
|
|
|
2015-07-08 19:08:02 +00:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2015-03-20 15:22:27 +00:00
|
|
|
seek = withWords start
|
|
|
|
|
|
|
|
start :: [String] -> CommandStart
|
|
|
|
start (ks:us:[]) = do
|
|
|
|
ls <- loggedLocations k
|
|
|
|
if toUUID us `elem` ls
|
|
|
|
then liftIO exitSuccess
|
|
|
|
else liftIO exitFailure
|
|
|
|
where
|
|
|
|
k = fromMaybe (error "bad key") (file2key ks)
|
|
|
|
start _ = error "Wrong number of parameters"
|