diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-09 18:13:55 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-09 18:13:55 -0400 |
commit | d56429eefee3d2079ce7b45220844dc9a93f7e61 (patch) | |
tree | c419e52a94254558e3a4ed1772178bd3052fb73a /Messages.hs | |
parent | 60b279fb6885852d9d62dc1cf91d526523de9e75 (diff) |
drop incremental json object display; clean up code
This gets rid of quite a lot of ugly hacks around json generation.
I doubt that any real-world json parsers can parse incomplete objects, so
while it's not as nice to need to wait for the complete object, especially
for commands like `git annex info` that take a while, it doesn't seem worth
the added complexity.
This also causes the order of fields within the json objects to be
reordered. Since any real json parser shouldn't care, the only possible
problem would be with ad-hoc parsers of the old json output.
Diffstat (limited to 'Messages.hs')
-rw-r--r-- | Messages.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Messages.hs b/Messages.hs index 53f356c1d..0ab1f72bb 100644 --- a/Messages.hs +++ b/Messages.hs @@ -27,7 +27,7 @@ module Messages ( earlyWarning, warningIO, indent, - JSONChunk(..), + JSON.JSONChunk(..), maybeShowJSON, showFullJSON, showCustom, @@ -54,7 +54,6 @@ import Types.Messages import Types.ActionItem import Messages.Internal import qualified Messages.JSON as JSON -import Utility.JSONStream (JSONChunk(..)) import qualified Annex showStart :: String -> FilePath -> Annex () @@ -122,7 +121,7 @@ showEndFail :: Annex () showEndFail = showEndResult False showEndResult :: Bool -> Annex () -showEndResult ok = outputMessageFinal (JSON.end ok) $ endResult ok ++ "\n" +showEndResult ok = outputMessage (JSON.end ok) $ endResult ok ++ "\n" endResult :: Bool -> String endResult True = "ok" @@ -154,12 +153,12 @@ indent :: String -> String indent = intercalate "\n" . map (\l -> " " ++ l) . lines {- Shows a JSON chunk only when in json mode. -} -maybeShowJSON :: JSONChunk v -> Annex () -maybeShowJSON v = void $ withMessageState $ outputJSON (JSON.add v) False +maybeShowJSON :: JSON.JSONChunk v -> Annex () +maybeShowJSON v = void $ withMessageState $ outputJSON (JSON.add v) {- Shows a complete JSON value, only when in json mode. -} -showFullJSON :: JSONChunk v -> Annex Bool -showFullJSON v = withMessageState $ outputJSON (JSON.complete v) True +showFullJSON :: JSON.JSONChunk v -> Annex Bool +showFullJSON v = withMessageState $ outputJSON (JSON.complete v) {- Performs an action that outputs nonstandard/customized output, and - in JSON mode wraps its output in JSON.start and JSON.end, so it's |