summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-07-26 13:30:07 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-07-26 13:30:07 -0400
commit3eb54bb464b4566e5ea5fe9db5addc20231597d0 (patch)
tree265691703d3ee1c8f64dc6accc7dd0c30fbb3c3b /Command
parent4ee3e4194a716273f68641ba0312339ab7c70b8b (diff)
allow using Aeson for streaming JSON output
Keeping Text.JSON use for now, because it seems a better fit for most of the commands, which don't use very structured JSON objects, but just output whatever fields suites them. But this lets Aeson be used when a more structured data type is available to serialize to JSON.
Diffstat (limited to 'Command')
-rw-r--r--Command/Add.hs2
-rw-r--r--Command/AddUrl.hs2
-rw-r--r--Command/Find.hs2
-rw-r--r--Command/Info.hs4
-rw-r--r--Command/MetaData.hs2
-rw-r--r--Command/Status.hs2
6 files changed, 7 insertions, 7 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index d6a2e5bf7..9a658e444 100644
--- a/Command/Add.hs
+++ b/Command/Add.hs
@@ -146,7 +146,7 @@ perform file = do
cleanup :: Key -> Bool -> CommandCleanup
cleanup key hascontent = do
- maybeShowJSON [("key", key2file key)]
+ maybeShowJSON $ JSONObject [("key", key2file key)]
when hascontent $
logStatus key InfoPresent
return True
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 0370a2fc9..2b889ac19 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -356,7 +356,7 @@ cleanup u url file key mtmp = case mtmp of
)
where
go = do
- maybeShowJSON [("key", key2file key)]
+ maybeShowJSON $ JSONObject [("key", key2file key)]
when (isJust mtmp) $
logStatus key InfoPresent
setUrlPresent u key url
diff --git a/Command/Find.hs b/Command/Find.hs
index 08c720575..9cd075ed6 100644
--- a/Command/Find.hs
+++ b/Command/Find.hs
@@ -66,7 +66,7 @@ start o file key = ifM (limited <||> inAnnex key)
showFormatted :: Maybe Utility.Format.Format -> String -> [(String, String)] -> Annex ()
showFormatted format unformatted vars =
- unlessM (showFullJSON vars) $
+ unlessM (showFullJSON $ JSONObject vars) $
case format of
Nothing -> liftIO $ putStrLn unformatted
Just formatter -> liftIO $ putStr $
diff --git a/Command/Info.hs b/Command/Info.hs
index 05d6a01d3..4eae57e5b 100644
--- a/Command/Info.hs
+++ b/Command/Info.hs
@@ -250,7 +250,7 @@ nostat = return Nothing
json :: JSON j => (j -> String) -> StatState j -> String -> StatState String
json fmt a desc = do
j <- a
- lift $ maybeShowJSON [(desc, j)]
+ lift $ maybeShowJSON $ JSONObject [(desc, j)]
return $ fmt j
nojson :: StatState String -> String -> StatState String
@@ -374,7 +374,7 @@ transfer_list :: Stat
transfer_list = stat desc $ nojson $ lift $ do
uuidmap <- Remote.remoteMap id
ts <- getTransfers
- maybeShowJSON [(desc, map (uncurry jsonify) ts)]
+ maybeShowJSON $ JSONObject [(desc, map (uncurry jsonify) ts)]
return $ if null ts
then "none"
else multiLine $
diff --git a/Command/MetaData.hs b/Command/MetaData.hs
index 14e727fc7..3123a63d0 100644
--- a/Command/MetaData.hs
+++ b/Command/MetaData.hs
@@ -96,7 +96,7 @@ perform now o k = case getSet o of
cleanup :: Key -> CommandCleanup
cleanup k = do
l <- map unwrapmeta . fromMetaData <$> getCurrentMetaData k
- maybeShowJSON l
+ maybeShowJSON (JSONObject l)
showLongNote $ unlines $ concatMap showmeta l
return True
where
diff --git a/Command/Status.hs b/Command/Status.hs
index 260cf2ab4..f4270228d 100644
--- a/Command/Status.hs
+++ b/Command/Status.hs
@@ -43,7 +43,7 @@ displayStatus s = do
let c = statusChar s
absf <- fromRepo $ fromTopFilePath (statusFile s)
f <- liftIO $ relPathCwdToFile absf
- unlessM (showFullJSON [("status", [c]), ("file", f)]) $
+ unlessM (showFullJSON $ JSONObject [("status", [c]), ("file", f)]) $
liftIO $ putStrLn $ [c] ++ " " ++ f
-- Git thinks that present direct mode files are typechanged.