make maybeShowJSON also add to the buffer
This commit is contained in:
parent
089c592977
commit
4a09b4bbbd
2 changed files with 13 additions and 9 deletions
|
@ -155,15 +155,11 @@ indent = intercalate "\n" . map (\l -> " " ++ l) . lines
|
||||||
|
|
||||||
{- Shows a JSON chunk only when in json mode. -}
|
{- Shows a JSON chunk only when in json mode. -}
|
||||||
maybeShowJSON :: JSONChunk v -> Annex ()
|
maybeShowJSON :: JSONChunk v -> Annex ()
|
||||||
maybeShowJSON v = withMessageState $ \s -> case outputType s of
|
maybeShowJSON v = void $ withMessageState $ outputJSON (JSON.add v) False
|
||||||
JSONOutput -> liftIO $ JSON.add v
|
|
||||||
_ -> return ()
|
|
||||||
|
|
||||||
{- Shows a complete JSON value, only when in json mode. -}
|
{- Shows a complete JSON value, only when in json mode. -}
|
||||||
showFullJSON :: JSONChunk v -> Annex Bool
|
showFullJSON :: JSONChunk v -> Annex Bool
|
||||||
showFullJSON v = withMessageState $ \s -> case outputType s of
|
showFullJSON v = withMessageState $ outputJSON (JSON.complete v) True
|
||||||
JSONOutput -> liftIO $ JSON.complete v >> return True
|
|
||||||
_ -> return False
|
|
||||||
|
|
||||||
{- Performs an action that outputs nonstandard/customized output, and
|
{- Performs an action that outputs nonstandard/customized output, and
|
||||||
- in JSON mode wraps its output in JSON.start and JSON.end, so it's
|
- in JSON mode wraps its output in JSON.start and JSON.end, so it's
|
||||||
|
|
|
@ -26,8 +26,13 @@ outputMessage' endmessage json msg = withMessageState $ \s -> case outputType s
|
||||||
NormalOutput
|
NormalOutput
|
||||||
| concurrentOutputEnabled s -> concurrentMessage s False msg q
|
| concurrentOutputEnabled s -> concurrentMessage s False msg q
|
||||||
| otherwise -> liftIO $ flushed $ putStr msg
|
| otherwise -> liftIO $ flushed $ putStr msg
|
||||||
|
JSONOutput -> void $ outputJSON json endmessage s
|
||||||
|
QuietOutput -> q
|
||||||
|
|
||||||
|
outputJSON :: IO () -> Bool -> MessageState -> Annex Bool
|
||||||
|
outputJSON json endmessage s = case outputType s of
|
||||||
JSONOutput
|
JSONOutput
|
||||||
| concurrentOutputEnabled s ->
|
| concurrentOutputEnabled s -> do
|
||||||
-- Buffer json fragments until end is reached.
|
-- Buffer json fragments until end is reached.
|
||||||
if endmessage
|
if endmessage
|
||||||
then do
|
then do
|
||||||
|
@ -38,8 +43,11 @@ outputMessage' endmessage json msg = withMessageState $ \s -> case outputType s
|
||||||
json
|
json
|
||||||
else Annex.changeState $ \st ->
|
else Annex.changeState $ \st ->
|
||||||
st { Annex.output = s { jsonBuffer = json : jsonBuffer s } }
|
st { Annex.output = s { jsonBuffer = json : jsonBuffer s } }
|
||||||
| otherwise -> liftIO $ flushed json
|
return True
|
||||||
QuietOutput -> q
|
| otherwise -> do
|
||||||
|
liftIO $ flushed json
|
||||||
|
return True
|
||||||
|
_ -> return False
|
||||||
|
|
||||||
outputError :: String -> Annex ()
|
outputError :: String -> Annex ()
|
||||||
outputError msg = withMessageState $ \s ->
|
outputError msg = withMessageState $ \s ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue