Define a main function
It looks somewhat cleaner.
This commit is contained in:
parent
59af3a13f9
commit
f71c70ca7b
1 changed files with 9 additions and 7 deletions
16
linkwave.scm
16
linkwave.scm
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue