summaryrefslogtreecommitdiff
path: root/Messages.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Messages.hs')
-rw-r--r--Messages.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/Messages.hs b/Messages.hs
index a7f14f485..1294e44f6 100644
--- a/Messages.hs
+++ b/Messages.hs
@@ -20,6 +20,7 @@ module Messages (
warning,
indent,
maybeShowJSON,
+ showFullJSON,
showCustom,
showHeader,
showRaw,
@@ -90,10 +91,17 @@ warning' w = do
indent :: String -> String
indent = join "\n" . map (\l -> " " ++ l) . lines
-{- Shows a JSON value only when in json mode. -}
+{- Shows a JSON fragment only when in json mode. -}
maybeShowJSON :: JSON a => [(String, a)] -> Annex ()
maybeShowJSON v = handle (JSON.add v) q
+{- Shows a complete JSON value, only when in json mode. -}
+showFullJSON :: JSON a => [(String, a)] -> Annex Bool
+showFullJSON v = Annex.getState Annex.output >>= liftIO . go
+ where
+ go Annex.JSONOutput = JSON.complete v >> return True
+ go _ = 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
- a complete JSON document.