diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-22 22:03:18 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-23 01:08:19 -0400 |
commit | fdf02986cf2c7db74cc8ca8ebd2786922652ff9b (patch) | |
tree | d6a61cdf01df8b3e635f71a7dc3adfdd43a0a8f8 /Messages.hs | |
parent | 7227dd8f21f24c2ccadd38e1a3dec7b888a23e92 (diff) |
find --json
Diffstat (limited to 'Messages.hs')
-rw-r--r-- | Messages.hs | 10 |
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. |