From e1b0cee919d9439ce47ba9bd8d0ec9c06e0e1c50 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 5 Jul 2022 00:57:41 +0530 Subject: bin: Centralize `tissue pull' and `tissue run-web' configuration. * bin/tissue (default-configuration): New function. (tissue-pull, tissue-run-web): Use default-configuration. --- bin/tissue | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/bin/tissue b/bin/tissue index 36e9e3b..006a94a 100755 --- a/bin/tissue +++ b/bin/tissue @@ -214,6 +214,15 @@ Export the repository as a website to OUTPUT-DIRECTORY. (string->number (substring listen (1+ (string-index-right listen #\:)))))))) +(define (default-configuration) + "Return the default configuration options for the `tissue pull' and +`tissue run-web' subcommands." + `((listen . "127.0.0.1:8080") + (state-directory . "/var/lib/tissue") + ;; Assume current repository as default. + (hosts ("localhost" + (upstream-repository . ,(git-top-level)))))) + (define tissue-run-web (match-lambda* (("--help") @@ -241,8 +250,7 @@ Run a web search service reading configuration from CONFIG-FILE. result)))) invalid-option unrecognized-argument - ;; Default listen - '((listen . "127.0.0.1:8080"))))) + (default-configuration)))) (let ((listen-repl (assq-ref args 'listen-repl))) (when listen-repl (spawn-server (cond @@ -268,10 +276,7 @@ Run a web search service reading configuration from CONFIG-FILE. (acons 'css (tissue-configuration-web-css (load-config)) parameters))))) - (or (assq-ref args 'hosts) - ;; Assume current directory as default. - `(("localhost" - (indexed-repository . ,(getcwd)))))) + (assq-ref args 'hosts)) (assq-ref args 'state-directory)))))) ;; This is a noop, since the index is built on any tissue command. It @@ -432,9 +437,7 @@ Pull latest from upstream repositories. invalid-option (lambda (host result) (acons 'host host result)) - ;; Default configuration parameters - '((state-directory . "/var/lib/tissue") - (hosts . ()))))) + (default-configuration)))) (let ((state-directory (assq-ref args 'state-directory))) ;; Error out if state directory does not exist. (unless (file-exists? state-directory) -- cgit v1.2.3