aboutsummaryrefslogtreecommitdiff
path: root/scm/verbop.scm
diff options
context:
space:
mode:
Diffstat (limited to 'scm/verbop.scm')
-rw-r--r--scm/verbop.scm159
1 files changed, 85 insertions, 74 deletions
diff --git a/scm/verbop.scm b/scm/verbop.scm
index 5192b87..ee86035 100644
--- a/scm/verbop.scm
+++ b/scm/verbop.scm
@@ -1,5 +1,7 @@
-#! =GUILE_BINDIR=/guile -s
-=AUTOGENERATED=
+#! /bin/sh
+# aside from this initial boilerplate, this is actually -*- scheme -*- code
+main='(module-ref (resolve-module '\''(src verbop)) '\'main')'
+exec ${GUILE-guile} -l $0 -c "(apply $main (command-line))" "$@"
!#
;;;; This file is part of Ellinika
;;;; Copyright (C) 2011 Sergey Poznyakoff
@@ -17,6 +19,11 @@
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;;;
+
+;;; Main procedure
+(define-module (src verbop)
+ :export (verbop))
+
(use-modules (srfi srfi-1)
(xmltools xmltrans)
(ellinika elmorph)
@@ -742,78 +749,82 @@ Informational options:
(define (cons? p)
(and (pair? p) (not (list? p))))
-(for-each
- (lambda (x)
- (cond
- ((cons? x)
- (case (car x)
- ((cleanup)
- (set! cleanup-option #t))
- ((database)
- (add-conn-param #:db (cdr x)))
- ((host)
- (add-conn-param #:host (cdr x)))
- ((port)
- (add-conn-param #:port (string->number (cdr x))))
- ((password)
- (add-conn-param #:pass (cdr x)))
- ((user)
- (add-conn-param #:user (cdr x)))
- ((interface)
- (add-conn-param #:iface (cdr x)))
- ((verbose)
- (set! verbose-option #t))
- ((preserve)
- (set! preserve-option #t))
- ((debug)
- (set! debug-level (string->number (cdr x)))
- (set! ellinika:sql-verbose #t))
- ((dry-run)
- (set! ellinika:sql-dry-run #t)
- (set! ellinika:sql-verbose #t))
- ((help)
- (usage)
- (exit 0))))
- (else
- (set! input-files (cdr x)))))
- (getopt-long (command-line) grammar))
-
-(if (null? input-files)
- (begin
- (display "Input files not specified\n" (current-error-port))
- (exit 1)))
-
-(if (not (ellinika:sql-connect ellinika-sql-connection))
- (begin
- (display "Cannot connect to the database\n" (current-error-port))
- (exit 1)))
-(set! flect-ident (query-number "SELECT MAX(ident) FROM verbflect"))
-
-(cond
- (cleanup-option
- (ellinika:sql-query "DELETE FROM verbflect where ident > 99")
- (ellinika:sql-query "DELETE FROM verbclass")
- (ellinika:sql-query "DELETE FROM verbtense")
- (ellinika:sql-query "DELETE FROM irregular_root")
- (ellinika:sql-query "DELETE FROM individual_verb")))
-
-(set! class-list
- (cons "I"
- (if ellinika:sql-dry-run
- (list "A" "B1" "B2")
- (map
- car
- (ellinika:sql-query
- "SELECT DISTINCT conj FROM conjugation ORDER BY 1")))))
-
-
-(for-each
- (lambda (x)
- (if (not (xmltrans:parse-file x))
- (exit 1)))
- input-files)
-
-(ellinika:sql-disconnect)
+(define (main . args)
+ (for-each
+ (lambda (x)
+ (cond
+ ((cons? x)
+ (case (car x)
+ ((cleanup)
+ (set! cleanup-option #t))
+ ((database)
+ (add-conn-param #:db (cdr x)))
+ ((host)
+ (add-conn-param #:host (cdr x)))
+ ((port)
+ (add-conn-param #:port (string->number (cdr x))))
+ ((password)
+ (add-conn-param #:pass (cdr x)))
+ ((user)
+ (add-conn-param #:user (cdr x)))
+ ((interface)
+ (add-conn-param #:iface (cdr x)))
+ ((verbose)
+ (set! verbose-option #t))
+ ((preserve)
+ (set! preserve-option #t))
+ ((debug)
+ (set! debug-level (string->number (cdr x)))
+ (set! ellinika:sql-verbose #t))
+ ((dry-run)
+ (set! ellinika:sql-dry-run #t)
+ (set! ellinika:sql-verbose #t))
+ ((help)
+ (usage)
+ (exit 0))))
+ (else
+ (set! input-files (cdr x)))))
+ (getopt-long args grammar))
+
+ (if (null? input-files)
+ (begin
+ (display "Input files not specified\n" (current-error-port))
+ (exit 1)))
+
+ (if (not (ellinika:sql-connect ellinika-sql-connection))
+ (begin
+ (display "Cannot connect to the database\n" (current-error-port))
+ (exit 1)))
+ (set! flect-ident (query-number "SELECT MAX(ident) FROM verbflect"))
+
+ (cond
+ (cleanup-option
+ (ellinika:sql-query "DELETE FROM verbflect where ident > 99")
+ (ellinika:sql-query "DELETE FROM verbclass")
+ (ellinika:sql-query "DELETE FROM verbtense")
+ (ellinika:sql-query "DELETE FROM irregular_root")
+ (ellinika:sql-query "DELETE FROM individual_verb")))
+
+ (set! class-list
+ (cons "I"
+ (if ellinika:sql-dry-run
+ (list "A" "B1" "B2")
+ (map
+ car
+ (ellinika:sql-query
+ "SELECT DISTINCT conj FROM conjugation ORDER BY 1")))))
+
+
+ (for-each
+ (lambda (x)
+ (if (not (xmltrans:parse-file x))
+ (exit 1)))
+ input-files)
+
+ (ellinika:sql-disconnect))
+
+;;;; EOF
+

Return to:

Send suggestions and report system problems to the System administrator.