Define a main function

It looks somewhat cleaner.
This commit is contained in:
Tom Willemsen 2012-12-28 01:42:21 +01:00
parent 59af3a13f9
commit f71c70ca7b

View file

@ -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)