diff options
Diffstat (limited to 'CmdLine/Batch.hs')
-rw-r--r-- | CmdLine/Batch.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/CmdLine/Batch.hs b/CmdLine/Batch.hs index cca93b0b3..82038314c 100644 --- a/CmdLine/Batch.hs +++ b/CmdLine/Batch.hs @@ -48,15 +48,16 @@ batchBadInput Batch = liftIO $ putStrLn "" -- Reads lines of batch mode input and passes to the action to handle. batchInput :: (String -> Either String a) -> (a -> Annex ()) -> Annex () -batchInput parser a = do - mp <- liftIO $ catchMaybeIO getLine - case mp of - Nothing -> return () - Just v -> do - either parseerr a (parser v) - batchInput parser a +batchInput parser a = go =<< batchLines where - parseerr s = error $ "Batch input parse failure: " ++ s + go [] = return () + go (l:rest) = do + either parseerr a (parser l) + go rest + parseerr s = giveup $ "Batch input parse failure: " ++ s + +batchLines :: Annex [String] +batchLines = liftIO $ lines <$> getContents -- Runs a CommandStart in batch mode. -- |