From 2d5e11dece7476ba9b777e19c717314f26dd031d Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 5 Jul 2022 00:25:13 +0530 Subject: bin: Pass configuration file to `tissue run-web' as an option. * bin/tissue (tissue-run-web): Accept configuration file as a command-line option. (unrecognized-argument): New function. --- bin/tissue | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/tissue b/bin/tissue index 789cdb8..28aa68f 100755 --- a/bin/tissue +++ b/bin/tissue @@ -66,6 +66,9 @@ exec guile --no-auto-compile -s "$0" "$@" (define (invalid-option opt name arg loads) (error "Invalid option" name)) +(define (unrecognized-argument arg loads) + (error "Unrecognized argument" arg)) + (define (command-line-program) "Return the name, that is arg0, of the command-line program invoked to run tissue." @@ -214,10 +217,11 @@ Export the repository as a website to OUTPUT-DIRECTORY. (define tissue-run-web (match-lambda* (("--help") - (format #t "Usage: ~a run-web CONFIG-FILE + (format #t "Usage: ~a run-web [OPTIONS] Run a web search service reading configuration from CONFIG-FILE. - --listen-repl=P run REPL server listening on port or path P + --listen-repl=P run REPL server listening on port or path P + -C, --config=CONFIG-FILE read configuration parameters from CONFIG-FILE " (command-line-program))) (args @@ -228,12 +232,15 @@ Run a web search service reading configuration from CONFIG-FILE. (acons 'listen-repl (or (string->number arg) arg) - result)))) + result))) + (option '(#\C "config") + #t #f + (lambda (opt name config-file result) + (append (call-with-input-file config-file + read) + result)))) invalid-option - (lambda (config-file result) - (append (call-with-input-file config-file - read) - result)) + unrecognized-argument ;; Default listen '((listen . "127.0.0.1:8080"))))) (let ((listen-repl (assq-ref args 'listen-repl))) -- cgit v1.2.3