gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] 51/324: scripts: publish-store: add option for printing


From: gnunet
Subject: [gnunet-scheme] 51/324: scripts: publish-store: add option for printing generated JSON
Date: Tue, 21 Sep 2021 13:21:31 +0200

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a commit to branch master
in repository gnunet-scheme.

commit 83fe5f271c371fd03c7f373e5ecfdecbdc8e21e1
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Mon Jan 25 16:17:57 2021 +0100

    scripts: publish-store: add option for printing generated JSON
    
    * gnu/gnunet/scripts/publish-store.scm
      (%options-specification, %help, inner-main): recognise new option
      '--display-json'.
      (publish-nar): print generated to JSON when '--display-json' is used.
      (gnunet-publish): work around undesired rest argument behaviour.
---
 gnu/gnunet/scripts/publish-store.scm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/gnu/gnunet/scripts/publish-store.scm 
b/gnu/gnunet/scripts/publish-store.scm
index 2fdf689..a3f2f20 100644
--- a/gnu/gnunet/scripts/publish-store.scm
+++ b/gnu/gnunet/scripts/publish-store.scm
@@ -68,6 +68,8 @@
        (input    (single-char #\i)
                  (value #t))
        (simulate (single-char #\s))
+       ;; Debugging options
+       (display-json)
        ;; GNUnet options
        (config      (single-char #\c)
                     (value #t))
@@ -91,6 +93,9 @@ Publish a (GNU Guix, or Nix) store item INPUT into GNUnet.
                    currently gnunet-nix-archive-json/0
   -i, --input      Store item to publish
 
+Debugging options
+      --display-json  Display generated JSON to stdout
+
 GNUnet options
   -c, --config       GNUnet configuration for publishing
   -a, --anonymity    Anonymity level for publishing
@@ -116,6 +121,8 @@ GNUnet options
               (let ((result
                      (publish-nar #:input (option-ref options 'input #f)
                                   #:simulate (option-ref options 'simulate #f)
+                                  #:display-json
+                                  (option-ref options 'display-json #f)
                                   #:config (option-ref options 'config #f)
                                   #:anonymity
                                   (string->number
@@ -134,14 +141,17 @@ GNUnet options
              (else ???))))
 
     (define* (publish-nar #:key input
+                         display-json
                          #:allow-other-keys
                          #:rest r)
       (let* ((sxml (store-item->sxml input))
             (publish-object
              (lambda (object)
-               (apply publish-object object r))))
-       (publish-object
-        (string->utf8 (apply publish-sxml->json sxml r)))))
+               (apply publish-object object r)))
+            (json (apply publish-sxml->json sxml r)))
+       (when display-json
+         (display (current-output-port) json))
+       (publish-object (string->utf8 json))))
 
     (define gnunet-publish-uri-regexp
       (make-regexp "\\b(gnunet://fs/chk/([A-Z0-9]+).([A-Z0-9]+).[0-9]+)\\b"))
@@ -152,6 +162,7 @@ GNUnet options
                             #:key
                             ;; FIXME this shouldn't matter
                             input
+                            display-json
                             (config (string-append
                                      (getenv "HOME")
                                      "/.config/gnunet.conf"))

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]