From f71c70ca7b47cbb9c77b1e85de09ee858aca43dd Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 28 Dec 2012 01:42:21 +0100 Subject: [PATCH] Define a main function It looks somewhat cleaner. --- linkwave.scm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/linkwave.scm b/linkwave.scm index 455b0a2..2107f44 100644 --- a/linkwave.scm +++ b/linkwave.scm @@ -40,16 +40,18 @@ (or (string= (substring str 0 7) "http://") (string= (substring str 0 8) "https://")))) -(define db (open-database (data-file "linkwave.db"))) - -(let ((cla (command-line-arguments))) - (if (null? cla) +(define (main args) + (if (null? args) (for-each-row print-row db "select * from bookmark") (cond - ((url-string? (car cla)) + ((url-string? (car args)) (with-transaction - db (lambda () (add-bookmark (car cla) (cadr cla) (caddr cla) (cdddr cla)) #t))) + db (lambda () (add-bookmark (car args) (cadr args) (caddr args) (cdddr args)) #t))) (else - (format #t "Unrecognized option: ~a~%" (car cla)))))) + (format #t "Unrecognized option: ~a~%" (car args)))))) + +(define db (open-database (data-file "linkwave.db"))) + +(main (command-line-arguments)) (finalize! db #t)