From 2a878fd9ee2d99cf3112768449e4a0c4c3e77d8b Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sun, 4 Jan 2015 22:47:05 -0500 Subject: 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'. --- .gitignore | 1 + configure.ac | 2 +- haunt/config.scm | 39 --------------------------------------- haunt/config.scm.in | 42 ++++++++++++++++++++++++++++++++++++++++++ haunt/ui.scm | 19 +++++++++++++++++-- haunt/ui/serve.scm | 2 ++ 6 files changed, 63 insertions(+), 42 deletions(-) delete mode 100644 haunt/config.scm create mode 100644 haunt/config.scm.in diff --git a/.gitignore b/.gitignore index f696b42..7d8a9cb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ *.go *~ .#* +/haunt/config.scm diff --git a/configure.ac b/configure.ac index 3c35c09..4281e57 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([color-tests -Wall -Wno-portability foreign]) 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]) GUILE_PROGS([2.0.11]) diff --git a/haunt/config.scm b/haunt/config.scm deleted file mode 100644 index 53dc404..0000000 --- a/haunt/config.scm +++ /dev/null @@ -1,39 +0,0 @@ -;;; Haunt --- Static site generator for GNU Guile -;;; Copyright © 2015 David Thompson -;;; -;;; This file is part of Haunt. -;;; -;;; Haunt 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. -;;; -;;; Haunt 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 Haunt. If not, see . - -;;; Commentary: -;; -;; Haunt configuration. -;; -;;; Code: - -(define-module (haunt config) - #:export (%haunt-cwd - haunt-file-name - haunt-output-directory)) - -(define %haunt-cwd (getcwd)) - -(define (haunt-file-name rel) - "Return an absolute file name to the file REL in the haunt current -working directory." - (string-append %haunt-cwd "/" rel)) - -(define (haunt-output-directory) - "Return the current haunt compiled page output directory." - (haunt-file-name "output")) diff --git a/haunt/config.scm.in b/haunt/config.scm.in new file mode 100644 index 0000000..641d894 --- /dev/null +++ b/haunt/config.scm.in @@ -0,0 +1,42 @@ +;;; Haunt --- Static site generator for GNU Guile +;;; Copyright © 2015 David Thompson +;;; +;;; This file is part of Haunt. +;;; +;;; Haunt 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. +;;; +;;; Haunt 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 Haunt. If not, see . + +;;; Commentary: +;; +;; Haunt configuration. +;; +;;; Code: + +(define-module (haunt config) + #:export (%haunt-version + %haunt-cwd + haunt-file-name + haunt-output-directory)) + +(define %haunt-version "@PACKAGE_VERSION@") + +(define %haunt-cwd (getcwd)) + +(define (haunt-file-name rel) + "Return an absolute file name to the file REL in the haunt current +working directory." + (string-append %haunt-cwd "/" rel)) + +(define (haunt-output-directory) + "Return the current haunt compiled page output directory." + (haunt-file-name "output")) diff --git a/haunt/ui.scm b/haunt/ui.scm index 35e8eb3..910adf9 100644 --- a/haunt/ui.scm +++ b/haunt/ui.scm @@ -9,7 +9,7 @@ ;;; (at your option) any later version. ;;; ;;; 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 ;;; General Public License for more details. ;;; @@ -27,15 +27,17 @@ #:use-module (ice-9 ftw) #:use-module (ice-9 match) #:use-module (srfi srfi-26) + #:use-module (haunt config) #:export (program-name haunt-error + show-version-and-exit option? haunt-main)) (define commands '(serve)) -(define program-name (make-parameter "haunt")) +(define program-name (make-parameter 'haunt)) (define (haunt-error str . args) (format (current-error-port) "~a: " (program-name)) @@ -52,6 +54,17 @@ Run COMMAND with ARGS.~%~%") (format #t "Try `haunt --help' for more information.~%") (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 +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) (string-prefix? "-" str)) @@ -73,6 +86,8 @@ Run COMMAND with ARGS.~%~%") (show-haunt-usage)) ((or ("-h") ("--help")) (show-haunt-help)) + (("--version") + (show-version-and-exit)) (((? option? opt) _ ...) (format (current-error-port) "haunt: unrecognized option '~a'~%" diff --git a/haunt/ui/serve.scm b/haunt/ui/serve.scm index 3ef7ede..078b013 100644 --- a/haunt/ui/serve.scm +++ b/haunt/ui/serve.scm @@ -41,6 +41,8 @@ Start an HTTP server for the current site.~%") (() (serve (haunt-output-directory))) ((or ("-h") ("--help")) (show-serve-help)) + (("--version") + (show-version-and-exit)) (((? option? opt) _ ...) (haunt-error "invalid option: ~a" opt) (exit 1)) -- cgit v1.2.3