aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-05-29 18:14:24 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-05-29 18:17:48 +0200
commit9f414cb5721a84f54c15cfc9da808104e4e25a3c (patch)
treea23d8e1a9bd02ae6ce11df2d867ab3c5adb40504
parentAdd info output. (diff)
downloadcalp-9f414cb5721a84f54c15cfc9da808104e4e25a3c.tar.gz
calp-9f414cb5721a84f54c15cfc9da808104e4e25a3c.tar.xz
Reword how statprof is loaded.
-rwxr-xr-xmodule/main.scm75
-rw-r--r--module/output/import.scm31
2 files changed, 73 insertions, 33 deletions
diff --git a/module/main.scm b/module/main.scm
index 282b6ba5..6fb878a0 100755
--- a/module/main.scm
+++ b/module/main.scm
@@ -9,6 +9,7 @@
(srfi srfi-26)
(srfi srfi-41)
(srfi srfi-41 util)
+ (srfi srfi-88)
(util)
(vcomponent)
(vcomponent recurrence)
@@ -18,10 +19,14 @@
(output terminal)
(output none)
(output text)
+ (output import)
+ (output info)
(server)
(ice-9 getopt-long)
+ (statprof)
+
(parameters)
(config))
@@ -58,36 +63,40 @@
b a))
(define (main args)
- (let ((opts (getopt-long args options #:stop-at-first-non-option #t)))
- ((lambda (thunk)
- (let ((stprof (option-ref opts 'statprof #f)))
- (if stprof
- ((@ (statprof) statprof) thunk
- #:count-calls? #t
- #:port (current-error-port)
- #:display-style (if (boolean? stprof) 'flat (string->symbol stprof)))
- (thunk))))
-
- (lambda ()
- (with-output-to-port (open-output-port (option-ref opts 'output "-"))
- (lambda ()
- (if (option-ref opts 'format #f)
- (for-each (lambda (l) (display l) (newline))
- (flow-text
- (with-input-from-port (open-input-port (option-ref opts 'file "-"))
- (@ (ice-9 rdelim) read-string))))
-
- (init
- (lambda (c e)
- (let ((ropt (ornull (option-ref opts '() '())
- '("term"))))
- ((case (string->symbol (car ropt))
- ((none) none-main)
- ((html) html-main)
- ((term) terminal-main)
- ((server) server-main))
- c e ropt)))
- #:calendar-files (or (and=> (option-ref opts 'file #f)
- list)
- (calendar-files))))
- (newline)))))))
+ (define opts (getopt-long args options #:stop-at-first-non-option #t))
+ (define stprof (option-ref opts 'statprof #f))
+
+ (when stprof
+ (statprof-start))
+
+ (with-output-to-port (open-output-port (option-ref opts 'output "-"))
+ (lambda ()
+ (if (option-ref opts 'format #f)
+ (for-each (lambda (l) (display l) (newline))
+ (flow-text
+ (with-input-from-port (open-input-port (option-ref opts 'file "-"))
+ (@ (ice-9 rdelim) read-string))))
+
+ (init
+ (lambda (c e)
+ (let ((ropt (ornull (option-ref opts '() '())
+ '("term"))))
+ ((case (string->symbol (car ropt))
+ ((none) none-main)
+ ((html) html-main)
+ ((term) terminal-main)
+ ((import) import-main)
+ ((info) info-main)
+ ((server) server-main))
+ c e ropt)))
+ calendar-files: (or (and=> (option-ref opts 'file #f)
+ list)
+ (calendar-files))))
+ (newline)))
+
+ (when stprof
+ (statprof-stop)
+ (statprof-display (current-error-port)
+ style: (if (boolean? stprof)
+ 'flat
+ (string->symbol stprof)))))
diff --git a/module/output/import.scm b/module/output/import.scm
new file mode 100644
index 00000000..47f4fd47
--- /dev/null
+++ b/module/output/import.scm
@@ -0,0 +1,31 @@
+(define-module (output import)
+ :use-module (util))
+
+(define options
+ '((calendar (value #t) (single-char #\c))
+ (source (value #t) (single-char #\f))
+ ))
+
+(define (import-main calenadrs events args)
+ (define opts (getopt-long args options))
+
+ (define calendar (option-ref opts 'calendar #f))
+
+ (unless calendar
+ (format (current-error-port)
+ "Everything wroong~%"))
+
+
+ ;; TODO save sourcetype and dir for vdir calendars
+
+ #;
+ (let ((component (make-vcomponent (option-ref args 'source "/dev/stdin")))) ;
+ ;
+ ;; Check UID ;
+ ;; Add to calendar ;
+ ;; Allocate file, save there ;
+ ;
+ )
+
+
+ )