0f18636c8a
Instead -J will behave as if it was built without concurrent-output support in this situation. Ie, it will be mostly quiet, except when there's an error. Note that it's not a problem for a filename to contain invalid utf-8 when in a utf-8 locale. That is handled ok by concurrent-output. It's only displaying unicode characters in a non-unicode locale that doesn't work.
40 lines
993 B
Haskell
40 lines
993 B
Haskell
{- git-annex output messages, including concurrent output to display regions
|
|
-
|
|
- Copyright 2010-2015 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
-}
|
|
|
|
module Messages.Internal where
|
|
|
|
import Common
|
|
import Annex
|
|
import Types.Messages
|
|
import Messages.Concurrent
|
|
|
|
withOutputType :: (OutputType -> Annex a) -> Annex a
|
|
withOutputType a = outputType <$> Annex.getState Annex.output >>= a
|
|
|
|
outputMessage :: IO () -> String -> Annex ()
|
|
outputMessage json s = withOutputType go
|
|
where
|
|
go NormalOutput = liftIO $
|
|
flushed $ putStr s
|
|
go QuietOutput = q
|
|
go o@(ConcurrentOutput {}) = concurrentMessage o False s q
|
|
go JSONOutput = liftIO $ flushed json
|
|
|
|
outputError :: String -> Annex ()
|
|
outputError s = withOutputType go
|
|
where
|
|
go o@(ConcurrentOutput {}) = concurrentMessage o True s (go NormalOutput)
|
|
go _ = liftIO $ do
|
|
hFlush stdout
|
|
hPutStr stderr s
|
|
hFlush stderr
|
|
|
|
q :: Monad m => m ()
|
|
q = noop
|
|
|
|
flushed :: IO () -> IO ()
|
|
flushed a = a >> hFlush stdout
|