aboutsummaryrefslogtreecommitdiff
path: root/module/entry-points/terminal.scm
blob: 9f486d90f44e98437e2141244877a624eeb16cd7 (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
(define-module (entry-points terminal)
  :export (main)
  :use-module (output terminal)
  :use-module (vcomponent)
  :use-module (ice-9 getopt-long)
  :use-module (datetime)
  :use-module (datetime util)
  :use-module (vulgar)
  )

(define options
  '((date (value #t) (single-char #\d))
    (file (value #t) (single-char #\f))))

(define (main args)
  (define opts (getopt-long args options))
  (define-values (calendars events)
    (cond [(option-ref opts 'file #f) => (compose load-calendars list)]
          [else (load-calendars)]))

  (let ((date (or (and=> (option-ref opts 'date #f) parse-freeform-date)
                  (current-date))))
    ;; (format (current-error-port) "len(events) = ~a~%" (stream-length events))
    (with-vulgar
     (lambda () (main-loop date events))))
)