blob: 0c1e1c3fe70b7871a1b30ccc7c4ead60313b4610 (
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
|
#!/usr/bin/guile \
-e main -s
!#
(add-to-load-path "/home/hugo/code/calp/module")
(use-modules
((calp util) :select (path-append))
(ice-9 getopt-long)
((xdg basedir) :prefix xdg-)
((rss-filter) :select (handle-feed)))
(define option-spec
`((output (single-char #\o)
(required? #f)
(value #t)
(description "Target directory for output files" (br)
"Defaults to " (i "$PWD") "."))
(help (single-char #\h)
(description "Print this help"))
(config-dir (required? #f)
(value #t)
(description "Defaults to " (i "$XDG_CONFIG_DIR/rss-filter")))
(quiet (value #f)
(description "Supress info output"))))
(define (display-no-config config-dir)
(format #t "Configuration directory [~a] doesn't exist, or is unreadable~%"
config-dir))
(define (main args)
(define opts (getopt-long args ((@ (calp util options) getopt-opt) option-spec)))
(define output-directory (option-ref opts 'output "."))
(define config-dir
(option-ref opts 'config-dir
(path-append (xdg-config-home)
"rss-filter")))
(define quiet? (option-ref opts 'quiet #f))
(when (option-ref opts 'help #f)
((@ (calp util options) print-arg-help) option-spec)
(exit 0))
(unless (file-exists? config-dir)
(display-no-config config-dir)
(exit 1))
(add-to-load-path config-dir)
(for-each (handle-feed output-directory quiet?) (@ (config) feeds)))
|