ui: Display version information.
* haunt/config.scm: Delete. * haunt/config.scm.in: New file. * haunt/ui.scm (show-version-and-exit): New procedure. (program-name): Change default value. (haunt-main): Add version option. * haunt/ui/serve.scm (haunt-serve): Likewise. * configure.ac (AC_CONFIG_FILES): Add 'haunt/config.scm'. * .gitignore: Ignore 'haunt/config.scm'.
This commit is contained in:
parent
f299cca709
commit
2a878fd9ee
|
@ -10,3 +10,4 @@
|
||||||
*.go
|
*.go
|
||||||
*~
|
*~
|
||||||
.#*
|
.#*
|
||||||
|
/haunt/config.scm
|
||||||
|
|
|
@ -6,7 +6,7 @@ AC_CONFIG_AUX_DIR([build-aux])
|
||||||
AM_INIT_AUTOMAKE([color-tests -Wall -Wno-portability foreign])
|
AM_INIT_AUTOMAKE([color-tests -Wall -Wno-portability foreign])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
AC_CONFIG_FILES([Makefile haunt/config.scm])
|
||||||
AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
|
AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
|
||||||
|
|
||||||
GUILE_PROGS([2.0.11])
|
GUILE_PROGS([2.0.11])
|
||||||
|
|
|
@ -23,10 +23,13 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(define-module (haunt config)
|
(define-module (haunt config)
|
||||||
#:export (%haunt-cwd
|
#:export (%haunt-version
|
||||||
|
%haunt-cwd
|
||||||
haunt-file-name
|
haunt-file-name
|
||||||
haunt-output-directory))
|
haunt-output-directory))
|
||||||
|
|
||||||
|
(define %haunt-version "@PACKAGE_VERSION@")
|
||||||
|
|
||||||
(define %haunt-cwd (getcwd))
|
(define %haunt-cwd (getcwd))
|
||||||
|
|
||||||
(define (haunt-file-name rel)
|
(define (haunt-file-name rel)
|
19
haunt/ui.scm
19
haunt/ui.scm
|
@ -9,7 +9,7 @@
|
||||||
;;; (at your option) any later version.
|
;;; (at your option) any later version.
|
||||||
;;;
|
;;;
|
||||||
;;; Haunt is distributed in the hope that it will be useful, but
|
;;; Haunt is distributed in the hope that it will be useful, but
|
||||||
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
;;; WITnnnHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
;;; General Public License for more details.
|
;;; General Public License for more details.
|
||||||
;;;
|
;;;
|
||||||
|
@ -27,15 +27,17 @@
|
||||||
#:use-module (ice-9 ftw)
|
#:use-module (ice-9 ftw)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
|
#:use-module (haunt config)
|
||||||
#:export (program-name
|
#:export (program-name
|
||||||
haunt-error
|
haunt-error
|
||||||
|
show-version-and-exit
|
||||||
option?
|
option?
|
||||||
haunt-main))
|
haunt-main))
|
||||||
|
|
||||||
(define commands
|
(define commands
|
||||||
'(serve))
|
'(serve))
|
||||||
|
|
||||||
(define program-name (make-parameter "haunt"))
|
(define program-name (make-parameter 'haunt))
|
||||||
|
|
||||||
(define (haunt-error str . args)
|
(define (haunt-error str . args)
|
||||||
(format (current-error-port) "~a: " (program-name))
|
(format (current-error-port) "~a: " (program-name))
|
||||||
|
@ -52,6 +54,17 @@ Run COMMAND with ARGS.~%~%")
|
||||||
(format #t "Try `haunt --help' for more information.~%")
|
(format #t "Try `haunt --help' for more information.~%")
|
||||||
(exit 1))
|
(exit 1))
|
||||||
|
|
||||||
|
(define (show-version-and-exit)
|
||||||
|
(let ((name (if (eq? (program-name) 'haunt)
|
||||||
|
"haunt"
|
||||||
|
(format #f "haunt ~a" (program-name)))))
|
||||||
|
(format #t "~a ~a
|
||||||
|
Copyright (C) 2015 the Haunt authors
|
||||||
|
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||||
|
This is free software: you are free to change and redistribute it.
|
||||||
|
There is NO WARRANTY, to the extent permitted by law.~%"
|
||||||
|
name %haunt-version)))
|
||||||
|
|
||||||
(define (option? str)
|
(define (option? str)
|
||||||
(string-prefix? "-" str))
|
(string-prefix? "-" str))
|
||||||
|
|
||||||
|
@ -73,6 +86,8 @@ Run COMMAND with ARGS.~%~%")
|
||||||
(show-haunt-usage))
|
(show-haunt-usage))
|
||||||
((or ("-h") ("--help"))
|
((or ("-h") ("--help"))
|
||||||
(show-haunt-help))
|
(show-haunt-help))
|
||||||
|
(("--version")
|
||||||
|
(show-version-and-exit))
|
||||||
(((? option? opt) _ ...)
|
(((? option? opt) _ ...)
|
||||||
(format (current-error-port)
|
(format (current-error-port)
|
||||||
"haunt: unrecognized option '~a'~%"
|
"haunt: unrecognized option '~a'~%"
|
||||||
|
|
|
@ -41,6 +41,8 @@ Start an HTTP server for the current site.~%")
|
||||||
(() (serve (haunt-output-directory)))
|
(() (serve (haunt-output-directory)))
|
||||||
((or ("-h") ("--help"))
|
((or ("-h") ("--help"))
|
||||||
(show-serve-help))
|
(show-serve-help))
|
||||||
|
(("--version")
|
||||||
|
(show-version-and-exit))
|
||||||
(((? option? opt) _ ...)
|
(((? option? opt) _ ...)
|
||||||
(haunt-error "invalid option: ~a" opt)
|
(haunt-error "invalid option: ~a" opt)
|
||||||
(exit 1))
|
(exit 1))
|
||||||
|
|
Loading…
Reference in New Issue