aboutsummaryrefslogtreecommitdiff
path: root/Messages.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Messages.hs')
-rw-r--r--Messages.hs6
1 files changed, 6 insertions, 0 deletions
diff --git a/Messages.hs b/Messages.hs
index 87d414f17..faa4dbcde 100644
--- a/Messages.hs
+++ b/Messages.hs
@@ -19,12 +19,14 @@ module Messages (
showErr,
warning,
indent,
+ maybeShowJSON,
setupConsole
) where
import Control.Monad.State (liftIO)
import System.IO
import Data.String.Utils
+import Text.JSON
import Types
import qualified Annex
@@ -106,5 +108,9 @@ handle json normal = do
Annex.QuietOutput -> q
Annex.JSONOutput -> liftIO json
+{- Shows a JSON value only when in json mode. -}
+maybeShowJSON :: JSON a => [(String, a)] -> Annex ()
+maybeShowJSON v = handle (JSON.add v) q
+
q :: Monad m => m ()
q = return ()