]> git.elephly.net Git - software/mumi.git/blob - scripts/mumi.in
Support live hacking.
[software/mumi.git] / scripts / mumi.in
1 #!@GUILE@ --no-auto-compile
2 -*- scheme -*-
3 -*- geiser-scheme-implementation: guile -*-
4 !#
5 ;;; mumi -- Mediocre, uh, mail interface
6 ;;; Copyright © 2016, 2017 Ricardo Wurmus <rekado@elephly.net>
7 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
8 ;;;
9 ;;; This file is part of mumi.
10 ;;;
11 ;;; mumi is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or
14 ;;; (at your option) any later version.
15 ;;;
16 ;;; mumi is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;;; General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with mumi. If not, see <http://www.gnu.org/licenses/>.
23
24 (use-modules (srfi srfi-1)
25 (srfi srfi-37)
26 (system repl server)
27 (mumi web server))
28
29 (define %default-repl-server-port
30 ;; Default port to run REPL server on, if --listen-repl is provided
31 ;; but no port is mentioned
32 37146)
33
34 (define %options
35 ;; Specifications of the command-line options
36 (list (option '("listen-repl") #f #t
37 (lambda (opt name arg result)
38 (let ((port (cond (arg => string->number)
39 (else %default-repl-server-port))))
40 (if port
41 (alist-cons 'listen-repl port
42 (alist-delete 'listen-repl result))
43 (error "invalid REPL server port" arg)))))))
44
45 (define %default-options
46 ;; Alist of default option values
47 `((listen-repl . #f)))
48
49 (define (parse-options args)
50 (args-fold
51 args %options
52 (lambda (opt name arg result)
53 (error "unrecognized option" name))
54 (lambda (arg result)
55 (error "extraneous argument" arg))
56 %default-options))
57
58 (let ((opts (parse-options (cdr (program-arguments)))))
59 (let ((repl-port (assoc-ref opts 'listen-repl)))
60 (when repl-port
61 (spawn-server (make-tcp-server-socket #:port repl-port)))))
62
63 (start-mumi-web-server 1234)