init: Support --json and --json-error-messages

Dunno how useful this will be, since about all that's accessible from
the json is whether it succeeded or failed, and the error messages
which were already on stderr.

Note that, when autoenabling a special remote, it would be possible for
one to stop and prompt or output not using Messages and so not output as
part of the json. I don't think that happens, but I'm not 100% sure
something doesn't manage to break it. Of course, the same could be the
case for commands that transfer objects. Using Annex.Init.autoEnableSpecialRemotes
in --json mode would avoid the problem, but I've chosen to wait until I
know it's needed to use it.

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

View file

@ -32,6 +32,7 @@ These commands have been updated to support --json:
* git-annex-dead
* git-annex-describe
* git-annex-unused
* git-annex-init
Provisional list of commands that don't support --json and maybe should:
@ -39,8 +40,6 @@ Provisional list of commands that don't support --json and maybe should:
* git-annex-configremote
* git-annex-enableremote
* git-annex-importfeed
* git-annex-init
* git-annex-initremote
* git-annex-merge
* git-annex-reinit
@ -57,6 +56,10 @@ These commands could support json, but I punted:
* git-annex-version (--raw already exists, and the output is fairly machine
parseable already. It would be possible to jsonize the output to make it
possibly more machine parseable. But I'm doubtful that would be useful.
* git-annex-importfeed (implemented w/o using usual command actions,
which makes warning messages not get put in any particular json record.
Same problem would also need to be fixed for [[doc/todo/importfeed_parallell]]
btw.)
These commands have been reviewed and should not support json: