summaryrefslogtreecommitdiff
path: root/scripts/mumi.in
diff options
context:
space:
mode:
authorArun Isaac <arunisaac@systemreboot.net>2018-09-05 16:21:23 +0530
committerRicardo Wurmus <rekado@elephly.net>2018-11-09 19:50:27 +0100
commit5d68d1d5a29a404f91cd89cbea72c3f557f65518 (patch)
treeb88f4ef9db92430b7a197a678ac1618dfaa3eaf5 /scripts/mumi.in
parent24addb127cc0d41ef07ea1b428512650f3e146e1 (diff)
Support live hacking.
* scripts/mumi.in: Spawn REPL server to support live hacking, if --listen-repl is provided on the command line.
Diffstat (limited to 'scripts/mumi.in')
-rw-r--r--scripts/mumi.in41
1 files changed, 40 insertions, 1 deletions
diff --git a/scripts/mumi.in b/scripts/mumi.in
index f5ade22..1b1c5e5 100644
--- a/scripts/mumi.in
+++ b/scripts/mumi.in
@@ -4,6 +4,7 @@
!#
;;; mumi -- Mediocre, uh, mail interface
;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This file is part of mumi.
;;;
@@ -20,5 +21,43 @@
;;; You should have received a copy of the GNU General Public License
;;; along with mumi. If not, see <http://www.gnu.org/licenses/>.
-(use-modules (mumi web server))
+(use-modules (srfi srfi-1)
+ (srfi srfi-37)
+ (system repl server)
+ (mumi web server))
+
+(define %default-repl-server-port
+ ;; Default port to run REPL server on, if --listen-repl is provided
+ ;; but no port is mentioned
+ 37146)
+
+(define %options
+ ;; Specifications of the command-line options
+ (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)))))))
+
+(define %default-options
+ ;; Alist of default option values
+ `((listen-repl . #f)))
+
+(define (parse-options args)
+ (args-fold
+ args %options
+ (lambda (opt name arg result)
+ (error "unrecognized option" name))
+ (lambda (arg result)
+ (error "extraneous argument" arg))
+ %default-options))
+
+(let ((opts (parse-options (cdr (program-arguments)))))
+ (let ((repl-port (assoc-ref opts 'listen-repl)))
+ (when repl-port
+ (spawn-server (make-tcp-server-socket #:port repl-port)))))
+
(start-mumi-web-server 1234)