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://") (or (string= (substring str 0 7) "http://")
(string= (substring str 0 8) "https://")))) (string= (substring str 0 8) "https://"))))
(define db (open-database (data-file "linkwave.db"))) (define (main args)
(if (null? args)
(let ((cla (command-line-arguments)))
(if (null? cla)
(for-each-row print-row db "select * from bookmark") (for-each-row print-row db "select * from bookmark")
(cond (cond
((url-string? (car cla)) ((url-string? (car args))
(with-transaction (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 (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) (finalize! db #t)