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 Command
|
|
|
|
import Logs.Location
|
|
|
|
|
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
|
2018-10-01 18:12:06 +00:00
|
|
|
seek = withWords (commandAction . start)
|
2015-03-20 15:22:27 +00:00
|
|
|
|
|
|
|
start :: [String] -> CommandStart
|
|
|
|
start (ks:us:[]) = do
|
|
|
|
ls <- loggedLocations k
|
|
|
|
if toUUID us `elem` ls
|
|
|
|
then liftIO exitSuccess
|
|
|
|
else liftIO exitFailure
|
|
|
|
where
|
2016-11-16 01:29:54 +00:00
|
|
|
k = fromMaybe (giveup "bad key") (file2key ks)
|
|
|
|
start _ = giveup "Wrong number of parameters"
|