summaryrefslogtreecommitdiff
path: root/Messages.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-09-09 12:57:42 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-09-09 12:57:42 -0400
commitcac7297784a4eb953f0d6108d7e67e97be9285ad (patch)
treeca0098b875209945e15de2f63f52463487eb5e43 /Messages.hs
parent70ad04b5fc21d39bdae85b08ec948359a28021e6 (diff)
disentangle concurrency and message type
This makes -Jn work with --json and --quiet, where before setting -Jn disabled those options. Concurrent json output is currently a mess though since threads output chunks over top of one-another.
Diffstat (limited to 'Messages.hs')
-rw-r--r--Messages.hs26
1 files changed, 12 insertions, 14 deletions
diff --git a/Messages.hs b/Messages.hs
index f1055efb8..61702530f 100644
--- a/Messages.hs
+++ b/Messages.hs
@@ -40,7 +40,7 @@ module Messages (
commandProgressDisabled,
outputMessage,
implicitMessage,
- withOutputType,
+ withMessageState,
) where
import System.Log.Logger
@@ -155,17 +155,15 @@ indent = intercalate "\n" . map (\l -> " " ++ l) . lines
{- Shows a JSON chunk only when in json mode. -}
maybeShowJSON :: JSONChunk v -> Annex ()
-maybeShowJSON v = withOutputType $ liftIO . go
- where
- go JSONOutput = JSON.add v
- go _ = return ()
+maybeShowJSON v = withMessageState $ \s -> case outputType s of
+ JSONOutput -> liftIO $ JSON.add v
+ _ -> return ()
{- Shows a complete JSON value, only when in json mode. -}
showFullJSON :: JSONChunk v -> Annex Bool
-showFullJSON v = withOutputType $ liftIO . go
- where
- go JSONOutput = JSON.complete v >> return True
- go _ = return False
+showFullJSON v = withMessageState $ \s -> case outputType s of
+ JSONOutput -> liftIO $ JSON.complete v >> return True
+ _ -> return False
{- Performs an action that outputs nonstandard/customized output, and
- in JSON mode wraps its output in JSON.start and JSON.end, so it's
@@ -216,11 +214,11 @@ debugEnabled = do
{- Should commands that normally output progress messages have that
- output disabled? -}
commandProgressDisabled :: Annex Bool
-commandProgressDisabled = withOutputType $ \t -> return $ case t of
- QuietOutput -> True
- JSONOutput -> True
- NormalOutput -> False
- ConcurrentOutput {} -> True
+commandProgressDisabled = withMessageState $ \s -> return $
+ case outputType s of
+ QuietOutput -> True
+ JSONOutput -> True
+ NormalOutput -> concurrentOutputEnabled s
{- Use to show a message that is displayed implicitly, and so might be
- disabled when running a certian command that needs more control over its