File: main.rkt

package info (click to toggle)
racket-mode 20210916git0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,076 kB
  • sloc: lisp: 10,354; makefile: 58
file content (35 lines) | stat: -rw-r--r-- 1,165 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#lang racket/base

(require racket/match
         racket/port
         version/utils
         "command-server.rkt"
         (only-in "image.rkt" emacs-can-use-svg!)
         "repl.rkt")

(module+ main
  (define expected-version "6.9")
  (define actual-version (version))
  (unless (version<=? expected-version actual-version)
    (error 'racket-mode "needs at least Racket ~a but you have ~a"
           expected-version
           actual-version))

  (define launch-token
    (match (current-command-line-arguments)
      [(vector (== "--auth") token svg-flag-str)
       (emacs-can-use-svg! svg-flag-str)
       token]
      [v
       (eprintf "Bad command-line arguments: ~v\n" v)
       (exit)]))

  ;; Save original current-{input output}-port to give to
  ;; command-server-loop for command I/O.
  (let ([stdin  (current-input-port)]
        [stdout (current-output-port)])
    ;; Set no-ops so e.g. rando print can't bork the command I/O.
    (parameterize ([current-input-port  (open-input-bytes #"")]
                   [current-output-port (open-output-nowhere)])
      (start-repl-session-server launch-token)
      (command-server-loop stdin stdout))))