diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-17 17:52:01 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-17 17:52:01 +0200 |
commit | 6a219c59e6506ee5326822a7ced0e6cd92b7b628 (patch) | |
tree | 3cf44cef098fb0a98137abd7942d8aa10592ddfc /module/entry-points/import.scm | |
parent | stuff. (diff) | |
download | calp-6a219c59e6506ee5326822a7ced0e6cd92b7b628.tar.gz calp-6a219c59e6506ee5326822a7ced0e6cd92b7b628.tar.xz |
Move a bunch of files into calp module.
Diffstat (limited to 'module/entry-points/import.scm')
-rw-r--r-- | module/entry-points/import.scm | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/module/entry-points/import.scm b/module/entry-points/import.scm deleted file mode 100644 index 956ccc91..00000000 --- a/module/entry-points/import.scm +++ /dev/null @@ -1,61 +0,0 @@ -(define-module (entry-points import) - :export (main) - :use-module (util) - :use-module (util options) - :use-module (ice-9 getopt-long) - :use-module (ice-9 rdelim) - :use-module (srfi srfi-1) - :use-module (output vdir) - :use-module (vcomponent) - :autoload (vcomponent instance) (global-event-object) - ) - -(define options - '((calendar (value #t) (single-char #\c) - (description "Name of calendar to import into")) - (file (value #t) (single-char #\f) - (description "ics file to import")) - (help (single-char #\h) - (description "Print this help.")))) - -(define (main args) - (define opts (getopt-long args (getopt-opt options))) - - (define cal-name (option-ref opts 'calendar #f)) - (define fname (option-ref opts 'file "/dev/stdin")) - - (when (option-ref opts 'help #f) - (print-arg-help options) - (throw 'return)) - - (let* ((calendars (get-calendars global-event-object)) - (calendar - (and cal-name - (find (lambda (c) (string=? cal-name (prop c 'NAME))) - (get-calendars global-event-object))))) - - (unless calendar - (format (current-error-port) "No calendar named ~s~%" cal-name) - (throw 'return)) - - (let ((new-events (parse-cal-path fname))) - - (format #t "About to the following ~a events into ~a~%~{~a~^~%~}~%" - (length (children new-events)) - (prop calendar 'NAME) - (map (extract 'SUMMARY) (children new-events))) - - (format #t "Continue? [Y/n] ") - - (let loop ((c #\space)) - (case c - [(#\n #\N) (throw 'return)] - [(#\y #\Y) (map (lambda (e) - (add-event calendar e) - (save-event e)) - (children new-events))] - [else - (let ((line (read-line))) - (loop (if (string-null? line) - #\Y (string-ref line 0))))])) - ))) |