diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-01-19 11:54:13 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-01-19 11:56:38 -0400 |
commit | 12b375f583773fc33f9f379d13622cd1892860a4 (patch) | |
tree | 15f2cfbc5c9b8b6a4b97503f493cc46f1e46c64e | |
parent | afbce3349b3bd7a97377839892da4118b909068f (diff) |
add, import: Support --json output.
Include added key in output.
-rw-r--r-- | Command/Add.hs | 4 | ||||
-rw-r--r-- | Command/Import.hs | 2 | ||||
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | doc/git-annex-add.mdwn | 5 | ||||
-rw-r--r-- | doc/git-annex-import.mdwn | 5 |
5 files changed, 15 insertions, 2 deletions
diff --git a/Command/Add.hs b/Command/Add.hs index b88dc52f7..0dea0a7b7 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -21,9 +21,10 @@ import Utility.InodeCache import Annex.FileMatcher import Annex.Version import qualified Database.Keys +import Types.Key cmd :: Command -cmd = notBareRepo $ withGlobalOptions (jobsOption : fileMatchingOptions) $ +cmd = notBareRepo $ withGlobalOptions (jobsOption : jsonOption : fileMatchingOptions) $ command "add" SectionCommon "add files to annex" paramPaths (seek <$$> optParser) @@ -126,6 +127,7 @@ perform file = do cleanup :: FilePath -> Key -> Maybe InodeCache -> Bool -> CommandCleanup cleanup file key mcache hascontent = do + maybeShowJSON [("key", key2file key)] ifM (isDirect <&&> pure hascontent) ( do l <- calcRepo $ gitAnnexLink file key diff --git a/Command/Import.hs b/Command/Import.hs index 7e8ce3b7a..4e9ff69dc 100644 --- a/Command/Import.hs +++ b/Command/Import.hs @@ -23,7 +23,7 @@ import Types.FileMatcher import Annex.FileMatcher cmd :: Command -cmd = withGlobalOptions (jobsOption : fileMatchingOptions) $ notBareRepo $ +cmd = withGlobalOptions (jobsOption : jsonOption : fileMatchingOptions) $ notBareRepo $ command "import" SectionCommon "move and add files from outside git working copy" paramPaths (seek <$$> optParser) diff --git a/debian/changelog b/debian/changelog index 0817d0be3..47b51ac38 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ git-annex (6.20160115) UNRELEASED; urgency=medium * Force output to be line-buffered, even when it's not connected to the terminal. This is particuarly important for commands with --batch output, which was not always being flushed at an appropriate time. + * add, import: Support --json output. -- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400 diff --git a/doc/git-annex-add.mdwn b/doc/git-annex-add.mdwn index 7f796fec1..382ea1e6f 100644 --- a/doc/git-annex-add.mdwn +++ b/doc/git-annex-add.mdwn @@ -54,6 +54,11 @@ annexed content, and other symlinks. Adds multiple files in parallel. This may be faster. For example: `-J4` +* `--json` + + Enable JSON output. This is intended to be parsed by programs that use + git-annex. Each line of output is a JSON object. + # SEE ALSO [[git-annex]](1) diff --git a/doc/git-annex-import.mdwn b/doc/git-annex-import.mdwn index ca37b81eb..d0ac5e77f 100644 --- a/doc/git-annex-import.mdwn +++ b/doc/git-annex-import.mdwn @@ -71,6 +71,11 @@ Several options can be used to adjust handling of duplicate files. Imports multiple files in parallel. This may be faster. For example: `-J4` +* `--json` + + Enable JSON output. This is intended to be parsed by programs that use + git-annex. Each line of output is a JSON object. + # CAVEATS Note that using `--deduplicate` or `--clean-duplicates` with the WORM |