unused: Support --json and --json-error-messages

Generalized AddJSONActionItemField to allow it to add several fields. Not entirely
happy with that, since the names of the fields have to be carefully chosen to
not conflict with other json fields. And fields added that way can't be parsed
back in FromJSON, except for the "fields" field that is special cased for metadata.
Still, I couldn't see another way to do it.

Also, omit file:null from the json output. Which does affect other commands,
eg git-annex whereis --all --json. Hopefully that won't break something that expects
a null file. If it did, that could be reverted, but it would be ugly to have
file:null in the unused --json

Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
Joey Hess 2023-05-08 14:39:12 -04:00
parent dd90c7abda
commit c208442292
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 40 additions and 16 deletions

View file

@ -31,6 +31,7 @@ These commands have been updated to support --json:
* git-annex-untrust
* git-annex-dead
* git-annex-describe
* git-annex-unused
Provisional list of commands that don't support --json and maybe should:
@ -41,13 +42,11 @@ Provisional list of commands that don't support --json and maybe should:
* git-annex-importfeed
* git-annex-init
* git-annex-initremote
* git-annex-inprogress
* git-annex-merge
* git-annex-reinit
* git-annex-reinject
* git-annex-renameremote
* git-annex-sync
* git-annex-unused
* git-annex-upgrade
These commands could support json, but I punted:
@ -110,3 +109,4 @@ These commands have been reviewed and should not support json:
* git-annex-adjust, git-annex-vadd, git-annex-vcycle, git-annex-vfilter, git-annex-view, git-annex-vpop
(no output that would be useful to a program using these. They enter a
new branch and git branch will tell what it is.)
* git-annex-inprogress (output is already machine readable)