Add version and help options to convert
Place the `version' and `display-version' items in `common.scm' so they can be easily used by both executables.
This commit is contained in:
parent
27bdb9bdd1
commit
f379783d28
4 changed files with 72 additions and 12 deletions
|
@ -1,11 +1,13 @@
|
|||
objects = paths.o common.o
|
||||
|
||||
.PHONY: all
|
||||
|
||||
all: linkwave convert
|
||||
linkwave: linkwave.scm paths.o
|
||||
linkwave: linkwave.scm $(objects)
|
||||
csc $^ -o $@
|
||||
|
||||
convert: convert.scm paths.o
|
||||
convert: convert.scm $(objects)
|
||||
csc $^ -o $@
|
||||
|
||||
paths.o: paths.scm
|
||||
$(objects): %.o: %.scm
|
||||
csc -c $^
|
||||
|
|
30
src/common.scm
Normal file
30
src/common.scm
Normal file
|
@ -0,0 +1,30 @@
|
|||
;;; linkwave -- Store/retrieve/manage bookmarks
|
||||
;; Copyright (C) 2012 Tom Willemsen <tom at ryuslash dot org>
|
||||
|
||||
;; This program is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Common variables and procedures, used by several or all parts of
|
||||
;; this program.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(declare (unit common))
|
||||
|
||||
(define version "0.1.0")
|
||||
|
||||
(define (display-version)
|
||||
;; Display linkwave's version number.
|
||||
(format #t "linkwave v~a~%" version))
|
|
@ -22,7 +22,8 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(declare (uses paths))
|
||||
(declare (uses paths
|
||||
common))
|
||||
|
||||
(require-extension sqlite3)
|
||||
(require-library srfi-4)
|
||||
|
@ -78,6 +79,36 @@
|
|||
(rename-file (data-file "nlinkwave.db") (data-file "linkwave.db"))
|
||||
(format #t "Database converted.~%")))
|
||||
|
||||
(if (file-exists? "/home/slash/.local/share/linkwave/nlinkwave.db")
|
||||
(format #t "Converted database already exists.~%")
|
||||
(convert))
|
||||
(define (display-help)
|
||||
;; Display linkwave's help message.
|
||||
(format #t (string-append
|
||||
"Usage: convert [options]...~%"
|
||||
"~%"
|
||||
"Possible options:~%"
|
||||
"~%"
|
||||
"--help, -h Display this help and exit~%"
|
||||
"--version, -v Output version information and exit~%")))
|
||||
|
||||
(define (main args)
|
||||
;; Convert an old database file unless a conversion database already
|
||||
;; exists.
|
||||
(if (null? args)
|
||||
(if (file-exists? (data-file "nlinkwave.db"))
|
||||
(format #t (string-append "Conversion database already exists. "
|
||||
"Something may have gone wrong during the last run~%"))
|
||||
(convert))
|
||||
(do ((arg (car args) (and (not (null? args))
|
||||
(car args))))
|
||||
((or (null? arg) (not arg)))
|
||||
(cond
|
||||
((or (string= arg "-v") (string= arg "--version"))
|
||||
(display-version)
|
||||
(exit 0))
|
||||
((or (string= arg "-h") (string= arg "--help"))
|
||||
(display-help)
|
||||
(exit 0))
|
||||
(else
|
||||
(format #t "Unrecognized option: ~a~%" (car args))))
|
||||
(set! args (cdr args)))))
|
||||
|
||||
(main (command-line-arguments))
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(declare (uses paths))
|
||||
(declare (uses paths
|
||||
common))
|
||||
|
||||
(require-extension sqlite3)
|
||||
(require-library posix srfi-4)
|
||||
|
@ -76,10 +77,6 @@
|
|||
(or (string= (substring str 0 7) "http://")
|
||||
(string= (substring str 0 8) "https://"))))
|
||||
|
||||
(define (display-version)
|
||||
;; Display linkwave's version number.
|
||||
(format #t "linkwave v~a~%" version))
|
||||
|
||||
(define (display-help)
|
||||
;; Display linkwave's help message.
|
||||
(format #t (string-append
|
||||
|
|
Loading…
Reference in a new issue