aboutsummaryrefslogtreecommitdiff
path: root/Command/Forget.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-11 00:42:32 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-11 00:42:32 -0400
commite2f434c2a07d8aa8a27eeeb6394bebd7684285ef (patch)
treece706ea24348ab4c3c2347569b7f6cd84ab7ec49 /Command/Forget.hs
parent45acd1f959b4c7e7381ac1f03b30f937330cfa88 (diff)
converted Forget and TestRemote
Diffstat (limited to 'Command/Forget.hs')
-rw-r--r--Command/Forget.hs40
1 files changed, 21 insertions, 19 deletions
diff --git a/Command/Forget.hs b/Command/Forget.hs
index 24789fe44..584b56f8a 100644
--- a/Command/Forget.hs
+++ b/Command/Forget.hs
@@ -16,28 +16,30 @@ import qualified Annex
import Data.Time.Clock.POSIX
cmd :: Command
-cmd = withOptions forgetOptions $
- command "forget" SectionMaintenance
- "prune git-annex branch history"
- paramNothing (withParams seek)
-
-forgetOptions :: [Option]
-forgetOptions = [dropDeadOption]
-
-dropDeadOption :: Option
-dropDeadOption = flagOption [] "drop-dead" "drop references to dead repositories"
-
-seek :: CmdParams -> CommandSeek
-seek ps = do
- dropdead <- getOptionFlag dropDeadOption
- withNothing (start dropdead) ps
-
-start :: Bool -> CommandStart
-start dropdead = do
+cmd = command "forget" SectionMaintenance
+ "prune git-annex branch history"
+ paramNothing (seek <$$> optParser)
+
+data ForgetOptions = ForgetOptions
+ { dropDead :: Bool
+ }
+
+optParser :: CmdParamsDesc -> Parser ForgetOptions
+optParser _ = ForgetOptions
+ <$> switch
+ ( long "drop-dead"
+ <> help "drop references to dead repositories"
+ )
+
+seek :: ForgetOptions -> CommandSeek
+seek = commandAction . start
+
+start :: ForgetOptions -> CommandStart
+start o = do
showStart "forget" "git-annex"
now <- liftIO getPOSIXTime
let basets = addTransition now ForgetGitHistory noTransitions
- let ts = if dropdead
+ let ts = if dropDead o
then addTransition now ForgetDeadRemotes basets
else basets
next $ perform ts =<< Annex.getState Annex.force