File size: 1,047 Bytes
3b70664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
(in-package #:nekod)

;; The Nekomata eval loop — infrastructure as a read-eval-print loop
(defun nekod-eval (form)
  "Evaluate an infrastructure form. Returns the result."
  (typecase form
    (container-spec form)  ; Already a spec, return as-is
    (symbol (if (boundp form) (symbol-value form) form))
    (cons
     (case (car form)
       (define-container (eval form))
       (with-failover (eval form))
       (t (eval form))))
    (t form)))

(defun nekod-repl ()
  "Interactive REPL for Nekomata infrastructure management."
  (format t "~&Nekomata ~a~%Type :quit to exit.~%nekod> " "0.1.0")
  (finish-output)
  (loop
    (let ((form (read *standard-input* nil :eof)))
      (when (eq form :eof) (return))
      (when (eq form :quit) (return))
      (handler-case
          (let ((result (nekod-eval form)))
            (format t "~&=> ~s~%nekod> " result)
            (finish-output))
        (nekomata-error (e)
          (format t "~&Error: ~a~%nekod> " (error-message e))
          (finish-output))))))