rekey, setpresentkey: Support --json and --json-error-messages

Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
Joey Hess 2023-05-04 16:03:54 -04:00
parent 9bc9421c08
commit 38fc5d3fc7
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 44 additions and 24 deletions

View file

@ -37,7 +37,8 @@ git-annex (10.20230408) UNRELEASED; urgency=medium
of core.sharedRepository and umask.
* initremote: Avoid creating a remote that is not encrypted when gpg is
broken.
* fix, log, rmurl, unannex: Support --json and --json-error-messages.
* Support --json and --json-error-messages in more commands
(fix, log, rekey, rmurl, setpresentkey, unannex)
* log: When --raw-date is used, display only seconds from the epoch, as
documented, omitting a trailing "s" that was included in the output
before.

View file

@ -25,10 +25,11 @@ import qualified Utility.RawFilePath as R
import System.PosixCompat.Files (linkCount, fileMode)
cmd :: Command
cmd = command "rekey" SectionPlumbing
"change keys used for files"
(paramRepeating $ paramPair paramPath paramKey)
(seek <$$> optParser)
cmd = withAnnexOptions [jsonOptions] $
command "rekey" SectionPlumbing
"change keys used for files"
(paramRepeating $ paramPair paramPath paramKey)
(seek <$$> optParser)
data ReKeyOptions = ReKeyOptions
{ reKeyThese :: CmdParams

View file

@ -12,7 +12,7 @@ import Logs.Location
import Logs.Presence.Pure
cmd :: Command
cmd = noCommit $
cmd = noCommit $ withAnnexOptions [jsonOptions] $
command "setpresentkey" SectionPlumbing
"change records of where key is present"
(paramPair paramKey (paramPair paramUUID "[1|0]"))

View file

@ -34,6 +34,16 @@ urls, and other such information from the old to the new key
Makes the `--batch` input be delimited by nulls instead of the usual
newlines.
* `--json`
Enable JSON output. This is intended to be parsed by programs that use
git-annex. Each line of output is a JSON object.
* `--json-error-messages`
Messages that would normally be output to standard error are included in
the JSON instead.
* Also the [[git-annex-common-options]](1) can be used.
# SEE ALSO

View file

@ -21,6 +21,16 @@ not present.
Enables batch mode, in which lines are read from stdin.
The line format is "key uuid [1|0]"
* `--json`
Enable JSON output. This is intended to be parsed by programs that use
git-annex. Each line of output is a JSON object.
* `--json-error-messages`
Messages that would normally be output to standard error are included in
the JSON instead.
* Also the [[git-annex-common-options]](1) can be used.
# SEE ALSO

View file

@ -9,6 +9,8 @@ These commands have been updated to support --json:
* git-annex-rmurl
* git-annex-log
* git-annex-fix
* git-annex-setpresentkey
* git-annex-rekey
Provisional list of commands that don't support --json and maybe should:
@ -18,21 +20,16 @@ Provisional list of commands that don't support --json and maybe should:
* git-annex-addunused
* git-annex-adjust
* git-annex-backends
* git-annex-benchmark
* git-annex-checkpresentkey
* git-annex-common-options
* git-annex-config
* git-annex-configremote
* git-annex-dead
* git-annex-describe
* git-annex-diffdriver
* git-annex-dropunused
* git-annex-edit
* git-annex-enable-tor
* git-annex-enableremote
* git-annex-expire
* git-annex-filter-branch
* git-annex-filter-process
* git-annex-forget
* git-annex-group
* git-annex-groupwanted
@ -40,32 +37,21 @@ Provisional list of commands that don't support --json and maybe should:
* git-annex-init
* git-annex-initremote
* git-annex-inprogress
* git-annex-matchexpression
* git-annex-matching-expression
* git-annex-merge
* git-annex-migrate
* git-annex-mincopies
* git-annex-multicast
* git-annex-numcopies
* git-annex-preferred-content
* git-annex-readpresentkey
* git-annex-reinit
* git-annex-reinject
* git-annex-rekey
* git-annex-remotedaemon
* git-annex-renameremote
* git-annex-repair
* git-annex-required
* git-annex-resolvemerge
* git-annex-restage
* git-annex-schedule
* git-annex-semitrust
* git-annex-setkey
* git-annex-setpresentkey
* git-annex-sync
* git-annex-transferkey
* git-annex-transferkeys
* git-annex-transferrer
* git-annex-trust
* git-annex-undo
* git-annex-ungroup
@ -84,7 +70,13 @@ Provisional list of commands that don't support --json and maybe should:
These commands have been reviewed and should not support json:
* git-annex-contentlocation, git-annex-lookupkey, git-annex-calckey (output already machine parseable)
* git-annex-contentlocation, git-annex-lookupkey, git-annex-calckey,
(plumbing, output already machine parseable)
* git-annex-setkey (plumbing)
* git-annex-checkpresentkey (plumbing, has batch interface with machine
parseable output)
* git-annex-readpresentkey (plumbing, no output)
* git-annex-matchexpression (no output)
* git-annex-list (because it's a compact display of whereis so no new information)
* git-annex-direct (deprecated noop)
* git-annex findref (deprecated, can use find to do same thing)
@ -93,7 +85,7 @@ These commands have been reviewed and should not support json:
structured)
* git-annex-pre-commit (used internally)
* git-annex-post-receive (used internally)
* git-annex-smudge (used internally)
* git-annex-smudge, git-annex-filter-process (run by git)
* git-annex-p2p (used internally)
* git-annex-shell (run by git)
* git-annex-assistant (too high level)
@ -102,3 +94,9 @@ These commands have been reviewed and should not support json:
* git-annex-test, git-annex testremote (ouput not useful to consume and generated by tasty)
* git-annex-fuzztest (output not useful to consume)
* git-annex-map (already generates machine-parseable output file, stdout is incidental)
* git-annex-transferkey, git-annex-transferkeys (plumbing)
* git-annex-transferrer (plumbing, has its own protocol)
* git-annex-resolvemerge (no output except to stderr)
* git-annex-diffdriver (run by git)
* git-annex-restage (no output)
* git-annex-benchmark (no useful output, and output generated by criterion)