aboutsummaryrefslogtreecommitdiff
path: root/Command/Dead.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-13 10:26:54 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-13 10:26:54 -0400
commit533a5242b66831d56fb437fb356ef906b4b4fe0a (patch)
tree6b2c1bb81b3a22fbab2fc9af2c3dd1f7c5e44b68 /Command/Dead.hs
parentacf8d5eb7d1e543a0cebb90b79d1b16695a1c5e3 (diff)
convert Dead, and allow multiple --key options
Diffstat (limited to 'Command/Dead.hs')
-rw-r--r--Command/Dead.hs25
1 files changed, 14 insertions, 11 deletions
diff --git a/Command/Dead.hs b/Command/Dead.hs
index e487b3b5e..04c754d07 100644
--- a/Command/Dead.hs
+++ b/Command/Dead.hs
@@ -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