add --batch
This commit is contained in:
parent
5a781f4e8f
commit
7d0ece86f6
6 changed files with 51 additions and 13 deletions
|
@ -134,15 +134,20 @@ includeCommandAction a = account =<< tryIO (callCommandAction a)
|
|||
- stages, without catching errors. Useful if one command wants to run
|
||||
- part of another command. -}
|
||||
callCommandAction :: CommandStart -> CommandCleanup
|
||||
callCommandAction = start
|
||||
callCommandAction = fromMaybe True <$$> callCommandAction'
|
||||
|
||||
{- Like callCommandAction, but returns Nothing when the command did not
|
||||
- perform any action. -}
|
||||
callCommandAction' :: CommandStart -> Annex (Maybe Bool)
|
||||
callCommandAction' = start
|
||||
where
|
||||
start = stage $ maybe skip perform
|
||||
perform = stage $ maybe failure cleanup
|
||||
cleanup = stage $ status
|
||||
stage = (=<<)
|
||||
skip = return True
|
||||
failure = showEndFail >> return False
|
||||
status r = showEndResult r >> return r
|
||||
skip = return Nothing
|
||||
failure = showEndFail >> return (Just False)
|
||||
status r = showEndResult r >> return (Just r)
|
||||
|
||||
{- Do concurrent output when that has been requested. -}
|
||||
allowConcurrentOutput :: Annex a -> Annex a
|
||||
|
|
|
@ -54,3 +54,14 @@ batchInput parser a = do
|
|||
batchInput parser a
|
||||
where
|
||||
parseerr s = error $ "Batch input parse failure: " ++ s
|
||||
|
||||
-- Runs a CommandStart in batch mode.
|
||||
--
|
||||
-- The batch mode user expects to read a line of output, and it's up to the
|
||||
-- CommandStart to generate that output as it succeeds or fails to do its
|
||||
-- job. However, if it stops without doing anything, it won't generate
|
||||
-- any output, so in that case, batchBadInput is used to provide the caller
|
||||
-- with an empty line.
|
||||
batchCommandAction :: CommandStart -> Annex ()
|
||||
batchCommandAction a = maybe (batchBadInput Batch) (const noop)
|
||||
=<< callCommandAction' a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue