aboutsummaryrefslogtreecommitdiff
path: root/gnunet-guile
diff options
context:
space:
mode:
Diffstat (limited to 'gnunet-guile')
-rwxr-xr-xgnunet-guile72
1 files changed, 72 insertions, 0 deletions
diff --git a/gnunet-guile b/gnunet-guile
new file mode 100755
index 0000000..750cd04
--- /dev/null
+++ b/gnunet-guile
@@ -0,0 +1,72 @@
1#!/bin/sh
2# -*- mode: Scheme; indent-tabs-mode: nil; fill-column: 80; -*-
3exec guile -e '(@ (gnunet-guile) main)' -s "$0" "$@"
4!#
5;;;; Copyright © 2018 Amirouche Boubekki <amirouche@hypermove.net>
6;;;;
7;;;; This program is free software: you can redistribute it and/or modify
8;;;; it under the terms of the GNU General Public License as published by
9;;;; the Free Software Foundation, either version 3 of the License, or
10;;;; (at your option) any later version.
11;;;;
12;;;; This program is distributed in the hope that it will be useful,
13;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;;; GNU General Public License for more details.
16;;;;
17;;;; You should have received a copy of the GNU General Public License
18;;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19(define-module (gnunet-guile))
20
21(use-modules ((ice-9 getopt-long)))
22(use-modules ((ice-9 match)))
23
24(use-modules ((gnunet)))
25(use-modules ((gnunet subcommand)))
26
27
28;;; download
29
30(define %fs-handle #f)
31(define %fs-download #f)
32
33(define (progress info)
34 (pk (fs-progress-info-status info)))
35
36(define %download-options
37 '((help (single-char #\h) (value #f))))
38
39(define (download args)
40 "gnunet download CONFIGURATION URI FILENAME
41
42Download the URI to FILENAME using CONFIGURATION.
43"
44 (let ((options (getopt-long (cons "gnunet-guile download" args)
45 %download-options
46 #:stop-at-first-non-option #f)))
47 (if (option-ref options 'help #f)
48 (display (procedure-documentation download))
49 (match args
50 ((configuration uri filename)
51 (let ((configuration* (configuration-create)))
52 (configuration-load! configuration* configuration)
53 (scheduler-run
54 (lambda ()
55 (set! %fs-handle (fs-start configuration* "gnunet-guile" progress))
56 (fs-download-start %fs-handle
57 (string->uri uri)
58 0
59 #:filename filename)))))))))
60
61;;; publish
62
63(define (publish . args)
64 (pk 'publish args))
65
66;;; cli
67
68(define %cli `((download ,download)
69 (publish ,publish)))
70
71(define-public (main args)
72 (subcommand 'gnunet-guile %cli (cdr args)))