addurl: Added --with-files option.
This commit is contained in:
parent
03f2ae0423
commit
2dce8081a6
4 changed files with 37 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue