From 4e6cc41198515bf4926defd739766c2e1b43c9c9 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 9 Mar 2023 19:52:33 +0000 Subject: Add repl related options --- scripts/guix-qa-frontpage.in | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/guix-qa-frontpage.in b/scripts/guix-qa-frontpage.in index 7070592..0c27092 100644 --- a/scripts/guix-qa-frontpage.in +++ b/scripts/guix-qa-frontpage.in @@ -40,7 +40,15 @@ (define %options ;; Specifications of the command-line options - (list (option '("repl") #f #t + (list (option '("listen-repl") #f #t + (lambda (opt name arg result) + (let ((port (cond (arg => string->number) + (else %default-repl-server-port)))) + (if port + (alist-cons 'listen-repl port + (alist-delete 'listen-repl result)) + (error "invalid REPL server port" arg))))) + (option '("repl") #f #t (lambda (opt name arg result) (alist-cons 'repl #t (alist-delete 'repl result)))) (option '("pid-file") #t #f @@ -70,6 +78,11 @@ (lambda (opt name _ result) (alist-cons 'manage-patch-branches #t result))))) +(define %default-repl-server-port + ;; Default port to run REPL server on, if --listen-repl is provided + ;; but no port is mentioned + 37146) + (define %default-options ;; Alist of default option values `((port . 8765) @@ -100,6 +113,15 @@ (setvbuf (current-error-port) 'line) (let ((opts (parse-options (cdr (program-arguments))))) + (when (assq-ref opts 'repl) + ((@@ (ice-9 top-repl) call-with-sigint) + start-repl) + (exit 0)) + + (let ((repl-port (assoc-ref opts 'listen-repl))) + (when repl-port + (spawn-server (make-tcp-server-socket #:port repl-port)))) + (let ((pid-file (assq-ref opts 'pid-file))) (when pid-file (call-with-output-file pid-file -- cgit v1.2.3