summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-23 13:58:16 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-23 13:58:16 -0400
commitd811d5697259aaf0fe68f424edf33321ef2b0d5e (patch)
tree35e24d5949e5df675fc70f5fdb1f43579e4ed41d
parent84884101e3c19b0db4c8c5975fc47575dc0782fb (diff)
metadata: Support --json
-rw-r--r--Command/MetaData.hs10
-rw-r--r--debian/changelog1
-rw-r--r--doc/git-annex.mdwn2
3 files changed, 8 insertions, 5 deletions
diff --git a/Command/MetaData.hs b/Command/MetaData.hs
index 651cb4944..55d67c6b7 100644
--- a/Command/MetaData.hs
+++ b/Command/MetaData.hs
@@ -18,7 +18,7 @@ import qualified Data.Set as S
import Data.Time.Clock.POSIX
def :: [Command]
-def = [withOptions [setOption, tagOption, untagOption] $
+def = [withOptions [setOption, tagOption, untagOption, jsonOption] $
command "metadata" paramPaths seek
SectionMetaData "sets metadata of a file"]
@@ -62,8 +62,10 @@ perform now ms k = do
cleanup :: Key -> CommandCleanup
cleanup k = do
- m <- getCurrentMetaData k
- showLongNote $ unlines $ concatMap showmeta $ fromMetaData $ currentMetaData m
+ l <- map unwrapmeta . fromMetaData <$> getCurrentMetaData k
+ maybeShowJSON l
+ showLongNote $ unlines $ concatMap showmeta l
return True
where
- showmeta (f, vs) = map (\v -> fromMetaField f ++ "=" ++ fromMetaValue v) $ S.toList vs
+ unwrapmeta (f, v) = (fromMetaField f, map fromMetaValue (S.toList v))
+ showmeta (f, vs) = map ((f ++ "=") ++) vs
diff --git a/debian/changelog b/debian/changelog
index c336fc481..543504c12 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,7 @@ git-annex (5.20140222) UNRELEASED; urgency=medium
metadata (year and month) when adding files.
* metadata: Field names limited to alphanumerics and a few whitelisted
punctuation characters to avoid issues with views, etc.
+ * metadata: Support --json
-- Joey Hess <joeyh@debian.org> Fri, 21 Feb 2014 13:03:04 -0400
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index ab158a952..441da7b98 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -951,7 +951,7 @@ subdirectories).
Rather than the normal output, generate JSON. This is intended to be
parsed by programs that use git-annex. Each line of output is a JSON
object. Note that JSON output is only usable with some git-annex commands,
- like info, find, and whereis.
+ like info, find, whereis, and metadata.
* `--debug`