add, import: Support --json output.

Include added key in output.
This commit is contained in:
Joey Hess 2016-01-19 11:54:13 -04:00
parent aae77b1856
commit 7b8e79c0f0
Failed to extract signature
5 changed files with 15 additions and 2 deletions

View file

@ -21,9 +21,10 @@ import Utility.InodeCache
import Annex.FileMatcher import Annex.FileMatcher
import Annex.Version import Annex.Version
import qualified Database.Keys import qualified Database.Keys
import Types.Key
cmd :: Command cmd :: Command
cmd = notBareRepo $ withGlobalOptions (jobsOption : fileMatchingOptions) $ cmd = notBareRepo $ withGlobalOptions (jobsOption : jsonOption : fileMatchingOptions) $
command "add" SectionCommon "add files to annex" command "add" SectionCommon "add files to annex"
paramPaths (seek <$$> optParser) paramPaths (seek <$$> optParser)
@ -126,6 +127,7 @@ perform file = do
cleanup :: FilePath -> Key -> Maybe InodeCache -> Bool -> CommandCleanup cleanup :: FilePath -> Key -> Maybe InodeCache -> Bool -> CommandCleanup
cleanup file key mcache hascontent = do cleanup file key mcache hascontent = do
maybeShowJSON [("key", key2file key)]
ifM (isDirect <&&> pure hascontent) ifM (isDirect <&&> pure hascontent)
( do ( do
l <- calcRepo $ gitAnnexLink file key l <- calcRepo $ gitAnnexLink file key

View file

@ -23,7 +23,7 @@ import Types.FileMatcher
import Annex.FileMatcher import Annex.FileMatcher
cmd :: Command cmd :: Command
cmd = withGlobalOptions (jobsOption : fileMatchingOptions) $ notBareRepo $ cmd = withGlobalOptions (jobsOption : jsonOption : fileMatchingOptions) $ notBareRepo $
command "import" SectionCommon command "import" SectionCommon
"move and add files from outside git working copy" "move and add files from outside git working copy"
paramPaths (seek <$$> optParser) paramPaths (seek <$$> optParser)

1
debian/changelog vendored
View file

@ -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 * Force output to be line-buffered, even when it's not connected to the
terminal. This is particuarly important for commands with --batch terminal. This is particuarly important for commands with --batch
output, which was not always being flushed at an appropriate time. 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 -- Joey Hess <id@joeyh.name> Fri, 15 Jan 2016 14:05:01 -0400

View file

@ -54,6 +54,11 @@ annexed content, and other symlinks.
Adds multiple files in parallel. This may be faster. Adds multiple files in parallel. This may be faster.
For example: `-J4` 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 # SEE ALSO
[[git-annex]](1) [[git-annex]](1)

View file

@ -71,6 +71,11 @@ Several options can be used to adjust handling of duplicate files.
Imports multiple files in parallel. This may be faster. Imports multiple files in parallel. This may be faster.
For example: `-J4` 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 # CAVEATS
Note that using `--deduplicate` or `--clean-duplicates` with the WORM Note that using `--deduplicate` or `--clean-duplicates` with the WORM