summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorArun Isaac2022-07-21 01:10:38 +0530
committerArun Isaac2022-07-23 23:50:30 +0530
commit412920ef320356d8649de65e8a32b408900f9b9b (patch)
tree34c3d039f5efe7498bfafc130c8c6df7b96c2950 /bin
parent44a0ff3e06cad1afd57bf5899be07985a416a40f (diff)
downloadtissue-412920ef320356d8649de65e8a32b408900f9b9b.tar.gz
tissue-412920ef320356d8649de65e8a32b408900f9b9b.tar.lz
tissue-412920ef320356d8649de65e8a32b408900f9b9b.zip
bin: Add tissue web-dev subcommand.
* bin/tissue (tissue-web-dev): New function. (print-usage): List the tissue web-dev subcommand. (main): Call tissue-web-dev.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/tissue35
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/tissue b/bin/tissue
index e023b4e..e6ba96b 100755
--- a/bin/tissue
+++ b/bin/tissue
@@ -307,6 +307,39 @@ Build website of current repository.
(format (current-error-port)
"Built website.~%"))))
+(define tissue-web-dev
+ (match-lambda*
+ (("--help")
+ (format #t "Usage: ~a web-dev WEBSITE-DIRECTORY
+Serve current repository over HTTP.
+
+ --port=PORT run web server listening on PORT (default: 8080)
+ --listen-repl=P run REPL server listening on port or path P
+"
+ (command-line-program)))
+ (args
+ (let ((args (args-fold args
+ (list listen-repl-option
+ (option '("port")
+ #t #f
+ (lambda (opt name arg result)
+ (acons 'port
+ (string->number arg)
+ result))))
+ invalid-option
+ (lambda (arg result)
+ (acons 'website-directory arg result))
+ '((port . 8080)))))
+ (when (assq-ref args 'listen-repl)
+ (start-repl (assq-ref args 'listen-repl)))
+ (start-web-server (make-socket-address
+ AF_INET (inet-pton AF_INET "127.0.0.1") (assq-ref args 'port))
+ `(("localhost"
+ (css . ,(tissue-configuration-web-css (load-config)))
+ (repository-directory . ,(repository-directory (current-git-repository)))
+ (website-directory . ,(assq-ref args 'website-directory))
+ (xapian-directory . ,%xapian-index))))))))
+
;; This is a noop, since the index is built on any tissue command. It
;; exists just for the --help usage summary.
(define tissue-index
@@ -328,6 +361,7 @@ COMMAND must be one of the sub-commands listed below:
show show the text of an issue
repl run a Guile script in a tissue environment
web-build build website of current repository
+ web-dev serve current repository over HTTP
web serve one or more repositories over HTTP
pull pull latest from upstream repositories
index index files
@@ -506,6 +540,7 @@ Pull latest from upstream repositories.
("repl" tissue-repl)
("index" tissue-index)
("web-build" tissue-web-build)
+ ("web-dev" tissue-web-dev)
(invalid-command
(format (current-error-port) "Invalid command `~a'~%~%"
invalid-command)