summaryrefslogtreecommitdiff
path: root/haunt/ui/serve.scm
blob: 078b0132e0896877b316e5ae3bc3e3cea950e57c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
;;; Haunt --- Static site generator for GNU Guile
;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;;
;;; 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 <http://www.gnu.org/licenses/>.

;;; Commentary:
;;
;; Haunt serve sub-command.
;;
;;; Code:

(define-module (haunt ui serve)
  #:use-module (ice-9 match)
  #:use-module (haunt config)
  #:use-module (haunt ui)
  #:use-module (haunt serve web-server)
  #:export (haunt-serve))

(define (show-serve-help)
  (format #t "Usage: haunt serve [OPTION]
Start an HTTP server for the current site.~%")
  (display "
  -h, --help             display this help and exit")
  (newline))

(define haunt-serve
  (match-lambda*
   (() (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))
   ((arg _ ...)
    (haunt-error "invalid argument: ~a" arg)
    (exit 1))))