From 9f414cb5721a84f54c15cfc9da808104e4e25a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 29 May 2019 18:14:24 +0200 Subject: Reword how statprof is loaded. --- module/main.scm | 75 +++++++++++++++++++++++++++--------------------- module/output/import.scm | 31 ++++++++++++++++++++ 2 files changed, 73 insertions(+), 33 deletions(-) create mode 100644 module/output/import.scm 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 ; + ; + ) + + + ) -- cgit v1.2.3