2015-03-20 11:22:27 -04:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2015 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
2019-03-13 15:48:14 -04:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2015-03-20 11:22:27 -04:00
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.ReadPresentKey where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import Logs.Location
|
|
|
|
|
2015-07-08 12:33:27 -04:00
|
|
|
cmd :: Command
|
2015-07-08 15:08:02 -04:00
|
|
|
cmd = noCommit $
|
|
|
|
command "readpresentkey" SectionPlumbing
|
|
|
|
"read records of where key is present"
|
|
|
|
(paramPair paramKey paramUUID)
|
|
|
|
(withParams seek)
|
2015-03-20 11:22:27 -04:00
|
|
|
|
2015-07-08 15:08:02 -04:00
|
|
|
seek :: CmdParams -> CommandSeek
|
2018-10-01 14:12:06 -04:00
|
|
|
seek = withWords (commandAction . start)
|
2015-03-20 11:22:27 -04:00
|
|
|
|
|
|
|
start :: [String] -> CommandStart
|
|
|
|
start (ks:us:[]) = do
|
|
|
|
ls <- loggedLocations k
|
|
|
|
if toUUID us `elem` ls
|
|
|
|
then liftIO exitSuccess
|
|
|
|
else liftIO exitFailure
|
|
|
|
where
|
2019-01-14 13:17:47 -04:00
|
|
|
k = fromMaybe (giveup "bad key") (deserializeKey ks)
|
2016-11-15 21:29:54 -04:00
|
|
|
start _ = giveup "Wrong number of parameters"
|