From 6a6167d2888b7ddde00e1d2e9c9433714843d110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 17 Aug 2020 10:34:50 +0200 Subject: Change main to a module. --- main | 4 ++-- module/main.scm | 55 +++++++++++++++++++++++-------------------------------- 2 files changed, 25 insertions(+), 34 deletions(-) diff --git a/main b/main index 89c38e51..af2f489a 100755 --- a/main +++ b/main @@ -3,7 +3,7 @@ here=$(dirname $(realpath $0)) . $here/env -GUILE=${GUILE:-guile} +GUILE=${GUILE:-$(which guile)} # GUILE_LOAD_PATH=$here/module -exec $GUILE -e main -s $here/module/main.scm "$@" +exec $GUILE -c '((@ (main) main) (command-line))' "$@" diff --git a/module/main.scm b/module/main.scm index 2e9a8d5e..4d3e01a6 100644 --- a/module/main.scm +++ b/module/main.scm @@ -1,34 +1,25 @@ ;; -*- geiser-scheme-implementation: guile -*- +(define-module (main) + :use-module (util) -;; config + :use-module (srfi srfi-1) + :use-module (srfi srfi-88) ; keyword syntax -; (catch 'misc-error -; (lambda () (use-modules (autoconfig))) -; (lambda (err caller fmt args . rest) -; (if (eqv? (caadr args) 'autoconfig) -; (format (current-error-port) "Run ./configure first~%") -; (format (current-error-port) "~?~%" fmt args)) -; (exit 1))) + :use-module ((util config) :select (set-config! get-config get-configuration-documentation)) + :use-module (util options) + :use-module ((util hooks) :select (shutdown-hook)) + :use-module (directories) -(use-modules (srfi srfi-1) - (srfi srfi-88) ; keyword syntax + :use-module ((text markup) :select (sxml->ansi-text)) - (util) - ((util config) :select (set-config! get-config get-configuration-documentation)) - (util options) - ((util hooks) :select (shutdown-hook)) - (directories) + :use-module (ice-9 getopt-long) + :use-module (ice-9 regex) + :use-module ((ice-9 popen) :select (open-input-pipe)) - (text markup) + :use-module (statprof) + :use-module (repl) - (ice-9 getopt-long) - (ice-9 regex) - ((ice-9 popen) :select (open-input-pipe)) - - (statprof) - (repl) - - ) + ) (define options @@ -162,17 +153,17 @@ ) (when (option-ref opts 'update-zoneinfo #f) - (let ((pipe - (let-env ((PREFIX (get-config 'path-prefix))) - (open-input-pipe (path-append libexec "/tzget"))))) + (let ((pipe + (let-env ((PREFIX (get-config 'path-prefix))) + (open-input-pipe (path-append libexec "/tzget"))))) ;; (define path (read-line pipe)) (define names (string-split ((@ (ice-9 rdelim) read-line) pipe) #\space)) ((@ (util io) with-atomic-output-to-file) - (path-append data-directory "/zoneinfo.scm") - (lambda () - (write `(set-config! 'tz-list ',names)) (newline) - (write `(set-config! 'last-zoneinfo-upgrade ,((@ (datetime) current-date))) (newline)))))) + (path-append data-directory "/zoneinfo.scm") + (lambda () + (write `(set-config! 'tz-list ',names)) (newline) + (write `(set-config! 'last-zoneinfo-upgrade ,((@ (datetime) current-date))) (newline)))))) ;; always load zoneinfo if available. (let ((z (path-append data-directory "/zoneinfo"))) @@ -204,7 +195,7 @@ 'flat (string->symbol stprof))))) -(define (main args) +(define-public (main args) ((@ (util time) report-time!) "Program start") (dynamic-wind (lambda () 'noop) (lambda () (catch 'return (lambda () (wrapped-main args)) values)) -- cgit v1.2.3