This commit is contained in:
Joey Hess 2015-12-22 11:58:37 -04:00
parent d3240f4622
commit 03f2ae0423
Failed to extract signature
2 changed files with 5 additions and 13 deletions

View file

@ -31,15 +31,7 @@ batchable handler parser paramdesc = batchseeker <$> batchparser
<*> cmdParams paramdesc <*> cmdParams paramdesc
batchseeker (opts, NoBatch, params) = mapM_ (go NoBatch opts) params batchseeker (opts, NoBatch, params) = mapM_ (go NoBatch opts) params
batchseeker (opts, Batch, _) = batchloop opts batchseeker (opts, Batch, _) = batchInput (go Batch opts)
batchloop opts = do
mp <- liftIO $ catchMaybeIO getLine
case mp of
Nothing -> return ()
Just p -> do
go Batch opts p
batchloop opts
go batchmode opts p = go batchmode opts p =
unlessM (handler opts p) $ unlessM (handler opts p) $
@ -52,11 +44,11 @@ batchBadInput NoBatch = liftIO exitFailure
batchBadInput Batch = liftIO $ putStrLn "" batchBadInput Batch = liftIO $ putStrLn ""
-- Reads lines of batch mode input and passes to the action to handle. -- Reads lines of batch mode input and passes to the action to handle.
batchSeek :: (String -> Annex ()) -> Annex () batchInput :: (String -> Annex ()) -> Annex ()
batchSeek a = do batchInput a = do
mp <- liftIO $ catchMaybeIO getLine mp <- liftIO $ catchMaybeIO getLine
case mp of case mp of
Nothing -> return () Nothing -> return ()
Just p -> do Just p -> do
a p a p
batchSeek a batchInput a

View file

@ -94,7 +94,7 @@ seek :: AddUrlOptions -> CommandSeek
seek o = allowConcurrentOutput $ do seek o = allowConcurrentOutput $ do
forM_ (addUrls o) go forM_ (addUrls o) go
case batchOption o of case batchOption o of
Batch -> batchSeek go Batch -> batchInput go
NoBatch -> noop NoBatch -> noop
where where
go u = do go u = do