aboutsummaryrefslogtreecommitdiff
path: root/CmdLine/Batch.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-22 11:58:37 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-22 11:58:59 -0400
commit43b6da515e5becf0f7beea81af571794637bebd7 (patch)
tree3428ef0a31b503aef30d182fd63e2cfaef619580 /CmdLine/Batch.hs
parentae0059cac6a403cbeae66483a363fe64025beb69 (diff)
refactor
Diffstat (limited to 'CmdLine/Batch.hs')
-rw-r--r--CmdLine/Batch.hs16
1 files changed, 4 insertions, 12 deletions
diff --git a/CmdLine/Batch.hs b/CmdLine/Batch.hs
index ce9127975..f07f79b04 100644
--- a/CmdLine/Batch.hs
+++ b/CmdLine/Batch.hs
@@ -31,15 +31,7 @@ batchable handler parser paramdesc = batchseeker <$> batchparser
<*> cmdParams paramdesc
batchseeker (opts, NoBatch, params) = mapM_ (go NoBatch opts) params
- batchseeker (opts, Batch, _) = batchloop opts
-
- batchloop opts = do
- mp <- liftIO $ catchMaybeIO getLine
- case mp of
- Nothing -> return ()
- Just p -> do
- go Batch opts p
- batchloop opts
+ batchseeker (opts, Batch, _) = batchInput (go Batch opts)
go batchmode opts p =
unlessM (handler opts p) $
@@ -52,11 +44,11 @@ batchBadInput NoBatch = liftIO exitFailure
batchBadInput Batch = liftIO $ putStrLn ""
-- Reads lines of batch mode input and passes to the action to handle.
-batchSeek :: (String -> Annex ()) -> Annex ()
-batchSeek a = do
+batchInput :: (String -> Annex ()) -> Annex ()
+batchInput a = do
mp <- liftIO $ catchMaybeIO getLine
case mp of
Nothing -> return ()
Just p -> do
a p
- batchSeek a
+ batchInput a