summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-07-26 19:15:34 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-07-26 19:15:34 -0400
commitbcc5ee4f322a139ee7cef2bae1fc9bea9f5398ca (patch)
treed4bfd67f6efcb0000c8749aaa6cdae964b333edc /Command
parente0b3fc906467ded314c75417d5b11b4b04375d1a (diff)
Removed dependency on json library; all JSON is now handled by aeson.
I've eyeballed all --json commands, and the only difference should be that some fields are re-ordered.
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.hs25
-rw-r--r--Command/Status.hs2
5 files changed, 17 insertions, 16 deletions
diff --git a/Command/Add.hs b/Command/Add.hs
index 9a658e444..eeaaf5d34 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 $ JSONObject [("key", key2file key)]
+ maybeShowJSON $ JSONChunk [("key", key2file key)]
when hascontent $
logStatus key InfoPresent
return True
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 2b889ac19..326bf782b 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 $ JSONObject [("key", key2file key)]
+ maybeShowJSON $ JSONChunk [("key", key2file key)]
when (isJust mtmp) $
logStatus key InfoPresent
setUrlPresent u key url
diff --git a/Command/Find.hs b/Command/Find.hs
index 9cd075ed6..553ddc419 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 $ JSONObject vars) $
+ unlessM (showFullJSON $ JSONChunk vars) $
case format of
Nothing -> liftIO $ putStrLn unformatted
Just formatter -> liftIO $ putStr $
diff --git a/Command/Info.hs b/Command/Info.hs
index 4eae57e5b..bdc8afc34 100644
--- a/Command/Info.hs
+++ b/Command/Info.hs
@@ -11,8 +11,9 @@ module Command.Info where
import "mtl" Control.Monad.State.Strict
import qualified Data.Map.Strict as M
-import Text.JSON
+import qualified Data.Text as T
import Data.Ord
+import Data.Aeson hiding (json)
import Command
import qualified Git
@@ -34,7 +35,7 @@ import Logs.Transfer
import Types.TrustLevel
import Types.FileMatcher
import qualified Limit
-import Messages.JSON (DualDisp(..))
+import Messages.JSON (DualDisp(..), ObjectMap(..))
import Annex.BloomFilter
import qualified Command.Unused
@@ -247,10 +248,10 @@ simpleStat desc getval = stat desc $ json id getval
nostat :: Stat
nostat = return Nothing
-json :: JSON j => (j -> String) -> StatState j -> String -> StatState String
+json :: ToJSON j => (j -> String) -> StatState j -> String -> StatState String
json fmt a desc = do
j <- a
- lift $ maybeShowJSON $ JSONObject [(desc, j)]
+ lift $ maybeShowJSON $ JSONChunk [(desc, j)]
return $ fmt j
nojson :: StatState String -> String -> StatState String
@@ -374,7 +375,7 @@ transfer_list :: Stat
transfer_list = stat desc $ nojson $ lift $ do
uuidmap <- Remote.remoteMap id
ts <- getTransfers
- maybeShowJSON $ JSONObject [(desc, map (uncurry jsonify) ts)]
+ maybeShowJSON $ JSONChunk [(desc, map (uncurry jsonify) ts)]
return $ if null ts
then "none"
else multiLine $
@@ -388,11 +389,11 @@ transfer_list = stat desc $ nojson $ lift $ do
, maybe (fromUUID $ transferUUID t) Remote.name $
M.lookup (transferUUID t) uuidmap
]
- jsonify t i = toJSObject
- [ ("transfer", showLcDirection (transferDirection t))
- , ("key", key2file (transferKey t))
- , ("file", fromMaybe "" (associatedFile i))
- , ("remote", fromUUID (transferUUID t))
+ jsonify t i = object $ map (\(k, v) -> (T.pack k, v)) $
+ [ ("transfer", toJSON (showLcDirection (transferDirection t)))
+ , ("key", toJSON (key2file (transferKey t)))
+ , ("file", toJSON (associatedFile i))
+ , ("remote", toJSON (fromUUID (transferUUID t)))
]
disk_size :: Stat
@@ -415,9 +416,9 @@ disk_size = simpleStat "available local disk space" $
backend_usage :: Stat
backend_usage = stat "backend usage" $ json fmt $
- toJSObject . sort . M.toList . backendsKeys <$> cachedReferencedData
+ ObjectMap . backendsKeys <$> cachedReferencedData
where
- fmt = multiLine . map (\(b, n) -> b ++ ": " ++ show n) . fromJSObject
+ fmt = multiLine . map (\(b, n) -> b ++ ": " ++ show n) . sort . M.toList . fromObjectMap
numcopies_stats :: Stat
numcopies_stats = stat "numcopies stats" $ json fmt $
diff --git a/Command/Status.hs b/Command/Status.hs
index f4270228d..3a3bfa812 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 $ JSONObject [("status", [c]), ("file", f)]) $
+ unlessM (showFullJSON $ JSONChunk [("status", [c]), ("file", f)]) $
liftIO $ putStrLn $ [c] ++ " " ++ f
-- Git thinks that present direct mode files are typechanged.