rekey, setpresentkey: Support --json and --json-error-messages
authorJoey Hess <joeyh@joeyh.name>
Thu, 4 May 2023 20:03:54 +0000 (16:03 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 4 May 2023 20:03:54 +0000 (16:03 -0400)
Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
CHANGELOG
Command/ReKey.hs
Command/SetPresentKey.hs
doc/git-annex-rekey.mdwn
doc/git-annex-setpresentkey.mdwn
doc/todo/--json_for_unannex__and_ideally_any_other_command_.mdwn

index 9c03b01f978f097eee0bb3031c39ec874ef8fe44..b71895bffb167379ba7149adf95131f393133faf 100644 (file)
--- 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.
index 72e852fd11c2e3b1014da7401a3470b270d73cd2..5958f48ac57167188f5eb2c196a7accbe9226bd5 100644 (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
index 839d23cec7221a851f0ccb2404811e7de7368064..2b789a7e6b0e2bf9af0876caf0030355f752a471 100644 (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]"))
index 85458bdc55c96ea84494c920bdb05a222175e69e..aefa820dfb8652eee6c02f0b5941f8db6f69ff8a 100644 (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
index f72788bc9355c8d7ee2bc53dccd9f514e48a01e2..b12d7f36b7be6d4236a1d9467fb4129d63ffc971 100644 (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
index 8065f3abded218ed7d1ccde8a5553ec00f379c94..aeea979e83f6b297db63aa6b1ebceeb1da357020 100644 (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)