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)