aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-04-23 19:12:48 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-04-23 19:12:48 +0200
commit4810e380ed10c1983f00944d31716f1d0683b6a5 (patch)
tree42b09db2aa5fe98b832b015db8b5cd88a1ba4d04
parentFix terminal output. (diff)
downloadcalp-4810e380ed10c1983f00944d31716f1d0683b6a5.tar.gz
calp-4810e380ed10c1983f00944d31716f1d0683b6a5.tar.xz
Add command line option parsing.
-rw-r--r--module/html/html.scm33
-rwxr-xr-xmodule/main.scm21
2 files changed, 32 insertions, 22 deletions
diff --git a/module/html/html.scm b/module/html/html.scm
index 467ed413..3dcfdb55 100644
--- a/module/html/html.scm
+++ b/module/html/html.scm
@@ -145,19 +145,20 @@
car)
(group-stream events)))
- `(html (head
- (title "Calendar")
- (meta (@ (charset "utf-8")))
- ,(include-css "static/style.css")
- (style ,(format #f "~:{.CAL_~a { background-color: ~a; color: ~a }~%~}"
- (map (lambda (c)
- (list (html-attr (if (pair? (attr c 'NAME))
- (car (attr c 'NAME))
- (attr c 'NAME)))
- (or (attr c 'COLOR) "white")
- (or (and=> (attr c 'COLOR) calculate-fg-color) "black")))
- calendars))))
- (body (div (@ (class "calendar"))
- ,@(time-marker-div)
- (div (@ (class "days"))
- ,@(stream->list (stream-map lay-out-day evs)))))))
+ ((@ (sxml simple) sxml->xml)
+ `(html (head
+ (title "Calendar")
+ (meta (@ (charset "utf-8")))
+ ,(include-css "static/style.css")
+ (style ,(format #f "~:{.CAL_~a { background-color: ~a; color: ~a }~%~}"
+ (map (lambda (c)
+ (list (html-attr (if (pair? (attr c 'NAME))
+ (car (attr c 'NAME))
+ (attr c 'NAME)))
+ (or (attr c 'COLOR) "white")
+ (or (and=> (attr c 'COLOR) calculate-fg-color) "black")))
+ calendars))))
+ (body (div (@ (class "calendar"))
+ ,@(time-marker-div)
+ (div (@ (class "days"))
+ ,@(stream->list (stream-map lay-out-day evs))))))))
diff --git a/module/main.scm b/module/main.scm
index 760aedf8..58ea8ae7 100755
--- a/module/main.scm
+++ b/module/main.scm
@@ -23,6 +23,8 @@
(html html)
+ (ice-9 getopt-long)
+
(parameters)
)
@@ -156,10 +158,17 @@
(cons (list->stream regular)
(map generate-recurrence-set repeating))))))
+(define options
+ '((mode (value #t) (single-char #\m))
+ (date (value #t) (single-char #\d))
+ ))
+
(define (main args)
- ;; (init (lambda (calendars events)
- ;; (with-vulgar
- ;; (lambda () (main-loop events)))))
- ((@ (sxml simple) sxml->xml) (init html-main))
- (newline)
- )
+ (let ((opts (getopt-long args options #:stop-at-first-non-option #t)))
+ (init
+ (case (string->symbol (option-ref opts 'mode "term"))
+ ((html) html-main)
+ ((term) (lambda (calendars events)
+ (with-vulgar
+ (lambda () (main-loop events)))))))
+ (newline)))