2015-04-03 20:48:30 +00:00
|
|
|
{- git-annex output messages
|
|
|
|
-
|
|
|
|
- Copyright 2010-2014 Joey Hess <id@joeyh.name>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Messages.Internal where
|
|
|
|
|
|
|
|
import Common
|
|
|
|
import Types
|
|
|
|
import Types.Messages
|
|
|
|
import qualified Annex
|
|
|
|
|
|
|
|
handleMessage :: IO () -> IO () -> Annex ()
|
|
|
|
handleMessage json normal = withOutputType go
|
|
|
|
where
|
|
|
|
go NormalOutput = liftIO normal
|
|
|
|
go QuietOutput = q
|
2015-04-10 19:15:01 +00:00
|
|
|
go (ParallelOutput _) = q
|
2015-04-03 20:48:30 +00:00
|
|
|
go JSONOutput = liftIO $ flushed json
|
|
|
|
|
|
|
|
q :: Monad m => m ()
|
|
|
|
q = noop
|
|
|
|
|
|
|
|
flushed :: IO () -> IO ()
|
|
|
|
flushed a = a >> hFlush stdout
|
|
|
|
|
|
|
|
withOutputType :: (OutputType -> Annex a) -> Annex a
|
|
|
|
withOutputType a = outputType <$> Annex.getState Annex.output >>= a
|