convert Dead, and allow multiple --key options

This commit is contained in:
Joey Hess 2015-07-13 10:26:54 -04:00
parent adec382bc2
commit 3d8a8e9792
3 changed files with 17 additions and 13 deletions

View file

@ -72,7 +72,7 @@ import qualified Command.NumCopies
import qualified Command.Trust
import qualified Command.Untrust
import qualified Command.Semitrust
--import qualified Command.Dead
import qualified Command.Dead
import qualified Command.Group
import qualified Command.Wanted
import qualified Command.GroupWanted
@ -150,7 +150,7 @@ cmds =
, Command.Trust.cmd
, Command.Untrust.cmd
, Command.Semitrust.cmd
-- , Command.Dead.cmd
, Command.Dead.cmd
, Command.Group.cmd
, Command.Wanted.cmd
, Command.GroupWanted.cmd

View file

@ -9,26 +9,29 @@ module Command.Dead where
import Command
import Common.Annex
import qualified Annex
import Types.TrustLevel
import Types.Key
import Command.Trust (trustCommand)
import Logs.Location
import Remote (keyLocations)
import Git.Types
cmd :: Command
cmd = withOptions [keyOption] $
command "dead" SectionSetup "hide a lost repository or key"
(paramRepeating paramRemote) (withParams seek)
cmd = command "dead" SectionSetup "hide a lost repository or key"
(paramRepeating paramRemote) (seek <$$> optParser)
seek :: CmdParams -> CommandSeek
seek ps = maybe (trustCommand "dead" DeadTrusted ps) (flip seekKey ps)
=<< Annex.getField "key"
data DeadOptions = DeadRemotes [RemoteName] | DeadKeys [Key]
seekKey :: String -> CmdParams -> CommandSeek
seekKey ks = case file2key ks of
Nothing -> error "Invalid key"
Just key -> withNothing (startKey key)
optParser :: CmdParamsDesc -> Parser DeadOptions
optParser desc = (DeadRemotes <$> cmdParams desc)
<|> (DeadKeys <$> many (option (str >>= parseKey)
( long "key" <> metavar paramKey
<> help "keys whose content has been irretrievably lost"
)))
seek :: DeadOptions -> CommandSeek
seek (DeadRemotes rs) = trustCommand "dead" DeadTrusted rs
seek (DeadKeys ks) = seekActions $ pure $ map startKey ks
startKey :: Key -> CommandStart
startKey key = do

1
debian/changelog vendored
View file

@ -6,6 +6,7 @@
* Bash completion code is built-in to git-annex, and can be enabled by
running: source <(git-annex --bash-completion-script git-annex)
* version --raw now works when run outside a git repository.
* dead now accepts multiple --key options.
git-annex (5.20150710) unstable; urgency=medium