info --json: Improve json for "backend usage", using a nested object with fields for each backend instead of the previous weird nested lists. This may break existing parsers of this json output, if there were any.

This commit is contained in:
Joey Hess 2016-01-01 16:33:05 -04:00
parent 09a2fcb643
commit 121659576b
Failed to extract signature
3 changed files with 28 additions and 3 deletions

View file

@ -12,7 +12,6 @@ module Command.Info where
import "mtl" Control.Monad.State.Strict
import qualified Data.Map.Strict as M
import Text.JSON
import Data.Tuple
import Data.Ord
import Common.Annex
@ -403,9 +402,9 @@ disk_size = simpleStat "available local disk space" $
backend_usage :: Stat
backend_usage = stat "backend usage" $ json fmt $
sort . M.toList . backendsKeys <$> cachedReferencedData
toJSObject . sort . M.toList . backendsKeys <$> cachedReferencedData
where
fmt = multiLine . map (\(n, b) -> b ++ ": " ++ show n) . map swap
fmt = multiLine . map (\(b, n) -> b ++ ": " ++ show n) . fromJSObject
numcopies_stats :: Stat
numcopies_stats = stat "numcopies stats" $ json fmt $