blob: 452a40f9af9a7b3a3bde2f0c68d08861db805f8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!@GUILE@ \
--no-auto-compile -e main -s
!#
(use-modules (srfi srfi-1)
(config)
(config api)
(config licenses)
(config parser sexp)
(reading-heap heap)
(reading-heap media)
(reading-heap zmq))
(define config
(configuration
(name 'rh-server)
(synopsis "client for reading-heap")
(keywords
(list
(setting
(name 'media-library)
(synopsis "media library location")
(default (string-append (or (getenv "XDG_DATA_HOME")
(string-append (getenv "HOME")
"/.local/share"))
"/media-library"))
(character #f))
(setting
(name 'service-socket)
(synopsis "socket for communication with the service")
(default (string-append "ipc://" (or (getenv "XDG_RUNTIME_DIR")
"/tmp")
"/reading-heap.sock"))
(character #f))
(switch
(name 'write)
(synopsis "write the default config")
(default #f)
(test boolean?)
(character #f))
(switch
(name 'serve)
(synopsis "serve the media heap")
(default #f)
(test boolean?)
(character #t))
))
(directory (list (in-home ".reading-heap/")
(path (given
(string-append (or (getenv "XDG_CONFIG_HOME")
(string-append (getenv "HOME")
"/.config"))
"/reading-heap/"))
(eager? #t))))
(parser sexp-parser)
(copyright @COPYRIGHT@)
(version @HVERSION@)
(license @LICENSE@)
(author @AUTHOR@)))
(define (main cmd-line)
(let ((options (getopt-config-auto cmd-line config)))
(when (option-ref options 'write)
(options-write options))
(when (or (option-ref options 'serve)
(not (option-ref options 'write)))
(let* ((media (filetree->media-list (option-ref options 'media-library)))
(priorities (map media-priority media))
(heap (fold heap-insert 'E priorities media)))
(server-setup (option-ref options 'service-socket))
(rh-receive heap
(option-ref options 'media-library)
(string-append (option-ref options 'media-library) "/archive/"))))))
|