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

@ -19,7 +19,7 @@ import Control.Monad.Fail as Fail (MonadFail(..))
import qualified Data.Map as M
cmd :: Command
cmd = dontCheck repoExists $
cmd = dontCheck repoExists $ withAnnexOptions [jsonOptions] $
command "init" SectionSetup "initialize git-annex"
paramDesc (seek <$$> optParser)