diff --git a/CHANGELOG b/CHANGELOG index 9c03b01f97..b71895bffb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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. diff --git a/Command/ReKey.hs b/Command/ReKey.hs index 72e852fd11..5958f48ac5 100644 --- a/Command/ReKey.hs +++ b/Command/ReKey.hs @@ -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 diff --git a/Command/SetPresentKey.hs b/Command/SetPresentKey.hs index 839d23cec7..2b789a7e6b 100644 --- a/Command/SetPresentKey.hs +++ b/Command/SetPresentKey.hs @@ -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]")) diff --git a/doc/git-annex-rekey.mdwn b/doc/git-annex-rekey.mdwn index 85458bdc55..aefa820dfb 100644 --- a/doc/git-annex-rekey.mdwn +++ b/doc/git-annex-rekey.mdwn @@ -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 diff --git a/doc/git-annex-setpresentkey.mdwn b/doc/git-annex-setpresentkey.mdwn index f72788bc93..b12d7f36b7 100644 --- a/doc/git-annex-setpresentkey.mdwn +++ b/doc/git-annex-setpresentkey.mdwn @@ -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 diff --git a/doc/todo/--json_for_unannex__and_ideally_any_other_command_.mdwn b/doc/todo/--json_for_unannex__and_ideally_any_other_command_.mdwn index 8065f3abde..aeea979e83 100644 --- a/doc/todo/--json_for_unannex__and_ideally_any_other_command_.mdwn +++ b/doc/todo/--json_for_unannex__and_ideally_any_other_command_.mdwn @@ -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)