[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.
- [gnunet-scheme] 32/324: remove some uses of old accessors, (continued)
- [gnunet-scheme] 32/324: remove some uses of old accessors, gnunet, 2021/09/21
- [gnunet-scheme] 41/324: scripts: publish-store: fix predicate of --format option, gnunet, 2021/09/21
- [gnunet-scheme] 38/324: scripts: publish-store: publish whole trees, gnunet, 2021/09/21
- [gnunet-scheme] 37/324: scripts: publish-store: publish individual files, gnunet, 2021/09/21
- [gnunet-scheme] 40/324: scripts: publish-store: allow setting all options, gnunet, 2021/09/21
- [gnunet-scheme] 39/324: guix: suggest a package definition, gnunet, 2021/09/21
- [gnunet-scheme] 35/324: scripts: publish-store: compute file tree, gnunet, 2021/09/21
- [gnunet-scheme] 43/324: scripts: publish-store: exit after main function, gnunet, 2021/09/21
- [gnunet-scheme] 48/324: scripts: download-store: download json container, gnunet, 2021/09/21
- [gnunet-scheme] 45/324: scripts: publish-store: fix '--config' option parsing, gnunet, 2021/09/21
- [gnunet-scheme] 46/324: scripts: download-store: parse input arguments,
gnunet <=
- [gnunet-scheme] 42/324: scripts: publish-store: export some procedures, gnunet, 2021/09/21
- [gnunet-scheme] 44/324: doc: document publish-store.scm, gnunet, 2021/09/21
- [gnunet-scheme] 53/324: doc: add a section on Guix in the roadmap, gnunet, 2021/09/21
- [gnunet-scheme] 51/324: scripts: publish-store: add option for printing generated JSON, gnunet, 2021/09/21
- [gnunet-scheme] 52/324: scripts: download-store: add downloading procedure, gnunet, 2021/09/21
- [gnunet-scheme] 47/324: scripts: publish-store: don't index temporary files, gnunet, 2021/09/21
- [gnunet-scheme] 50/324: scripts: download-store: (partially) validate entries, gnunet, 2021/09/21
- [gnunet-scheme] 49/324: scripts: publish-store: correct file name creation, gnunet, 2021/09/21
- [gnunet-scheme] 57/324: mq: define priority and preference values, gnunet, 2021/09/21
- [gnunet-scheme] 59/324: Fix value creation in integer->value, gnunet, 2021/09/21