gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 46/324: scripts: download-store: parse input arguments


From: gnunet
Subject: [gnunet-scheme] 46/324: scripts: download-store: parse input arguments
Date: Tue, 21 Sep 2021 13:21:26 +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 ddb083f007488026b7b203dd9941de2de314e285
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Jan 23 21:09:32 2021 +0100

    scripts: download-store: parse input arguments
    
    * gnu/gnunet/scripts/download-store.scm
      (%supported-formats, %options-specification)
      (%version-string, %help): new constants
      (gnunet-fs-uri?): new procedure for recognising GNUnet FS URIs
      (main): new procedure wrapping inner-main
      (inner-main): new procedure, parsing input arguments and calling
      download-nar appropriately
      (download-nar): new stub procedure
---
 gnu/gnunet/scripts/download-store.scm | 111 ++++++++++++++++++++++++++++++++++
 1 file changed, 111 insertions(+)

diff --git a/gnu/gnunet/scripts/download-store.scm 
b/gnu/gnunet/scripts/download-store.scm
new file mode 100644
index 0000000..d17f9e0
--- /dev/null
+++ b/gnu/gnunet/scripts/download-store.scm
@@ -0,0 +1,111 @@
+;;   This file is part of scheme-GNUnet, a partial Scheme port of GNUnet.
+;;   Copyright (C) 2021 Maxime Devos <maximedevos@telenet.be>
+;;
+;;   GNUnet is free software: you can redistribute it and/or modify it
+;;   under the terms of the GNU Affero General Public License as published
+;;   by the Free Software Foundation, either version 3 of the License,
+;;   or (at your option) any later version.
+;;
+;;   GNUnet is distributed in the hope that it will be useful, but
+;;   WITHOUT ANY WARRANTY; without even the implied warranty of
+;;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;   Affero General Public License for more details.
+;;
+;;   You should have received a copy of the GNU Affero General Public License
+;;   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;
+;;   SPDX-License-Identifier: AGPL-3.0-or-later
+
+(library (gnu gnunet scripts download-store)
+  (export main)
+  (import (ice-9 optargs)
+         (ice-9 getopt-long)
+         (rnrs base)
+         (rnrs io simple)
+         (only (rnrs programs) exit)
+         (only (guile) string-prefix?)
+         (srfi srfi-1)
+         (srfi srfi-26))
+  (begin
+    (define %supported-formats
+      '("any" "gnunet-nix-archive-json/0"))
+
+    (define (gnunet-fs-uri? str)
+      (or (string-prefix? "gnunet://fs/chk" str)
+         (string-prefix? "gnunet://fs/loc" str)))
+
+    ;; TODO fit in a progress bar
+    (define %options-specification
+      `((version (single-char #\v))
+       (help    (single-char #\h))
+       (format  (single-char #\f)
+                (value #t)
+                (predicate ,(cute member <> %supported-formats)))
+       (input   (single-char #\i)
+                (value #t)
+                (predicate ,gnunet-fs-uri?))
+       (output  (single-char #\o)
+                (value #t))
+       ;; GNUnet options
+       (config      (single-char #\c)
+                    (value #t))
+       (anonymity   (single-char #\a)
+                    (value #t))
+       (no-network  (single-char #\n))
+       (parallelism (single-char #\p)
+                    (value #t))
+       (request-parallelism
+        (single-char #\r)
+        (value #t))))
+
+    (define %version-string
+      "scheme-gnunet download-store v0.0")
+
+    (define %help
+      "Usage: download-store [OPTIONS] -i URI -o FILENAME
+Download a store item from GNUnet using a GNUnet CHK or LOC URI
+(gnunet://fs/chk/...).
+
+The result may contain symbolic links and executables, beware!
+Download resumption is currently unsupported.
+
+  -v, --version    Print version information
+  -h, --help       Print this message
+  -f, --format     Representation of store items to use,
+                   'any' by default.
+  -i, --input      URI to download
+  -o, --output     Location to save store item at.
+
+GNUnet options
+  -c, --config      GNUnet configuration for publishing
+  -a, --anonymity   Anonymity level for downloading
+  -n, --no-network  Do not contact the network, only the
+                    local peer.")
+
+    (define (main arguments)
+      (inner-main arguments)
+      (exit 0))
+
+    (define (inner-main arguments)
+      (let ((options (getopt-long arguments %options-specification)))
+       (cond ((option-ref options 'version #f)
+              (display %version-string)
+              (newline))
+             ((option-ref options 'help #f)
+              (display %help)
+              (newline))
+             ((member (option-ref options 'format "gnunet-nix-archive-json/0")
+                      '("gnunet-nix-archive-json/0" "any"))
+              (download-nar #:input (option-ref options 'input #f)
+                            #:output (option-ref options 'output #f)
+                            #:config (option-ref options 'config #f)
+                            #:no-network (option-ref options 'no-network #f)
+                            #:anonymity
+                            (string->number
+                             (option-ref options 'anonymity "1"))))
+             (else ???))))
+
+    (define* (download-nar #:key
+                          #:allow-other-keys
+                          #:rest r)
+      ???)))

-- 
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]