diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-12-22 12:20:39 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-12-22 12:20:39 -0400 |
commit | b1e9cf0621394780763e96a3ce9a15cfbfa7f02e (patch) | |
tree | b8d72410b4bbfbc725f11b2f72c790587ec647f9 /CmdLine | |
parent | 43b6da515e5becf0f7beea81af571794637bebd7 (diff) |
addurl: Added --with-files option.
Diffstat (limited to 'CmdLine')
-rw-r--r-- | CmdLine/Batch.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/CmdLine/Batch.hs b/CmdLine/Batch.hs index f07f79b04..d8d210de4 100644 --- a/CmdLine/Batch.hs +++ b/CmdLine/Batch.hs @@ -31,7 +31,7 @@ batchable handler parser paramdesc = batchseeker <$> batchparser <*> cmdParams paramdesc batchseeker (opts, NoBatch, params) = mapM_ (go NoBatch opts) params - batchseeker (opts, Batch, _) = batchInput (go Batch opts) + batchseeker (opts, Batch, _) = batchInput Right (go Batch opts) go batchmode opts p = unlessM (handler opts p) $ @@ -44,11 +44,13 @@ batchBadInput NoBatch = liftIO exitFailure batchBadInput Batch = liftIO $ putStrLn "" -- Reads lines of batch mode input and passes to the action to handle. -batchInput :: (String -> Annex ()) -> Annex () -batchInput a = do +batchInput :: (String -> Either String a) -> (a -> Annex ()) -> Annex () +batchInput parser a = do mp <- liftIO $ catchMaybeIO getLine case mp of Nothing -> return () - Just p -> do - a p - batchInput a + Just v -> do + either parseerr a (parser v) + batchInput parser a + where + parseerr s = error $ "Batch input parse failure: " ++ s |