717d79cc1767135a90f13604e4f1d3504057ea9c
[clnl] / src / main / clnl / extensions / cli / cli.lisp
1 (in-package #:clnl-extension-cli)
2
3 (defmethod clnl-extensions:prims ((extension (eql :cli)))
4  (list
5   (list :name :q :type :command :func #'shut-down)
6   (list :name :load :type :command :args '(t) :func #'load-file)
7   (list :name :help :type :command :args '((:token :optional)) :precedence 20 :func #'help)
8   (list
9    :name :button :type :command :args '(:string (:number :optional))
10    :precedence 20 :func #'clnl-model:execute-button)))
11
12 (defun shut-down ()
13  (sb-ext:exit :abort t))
14
15 (defun load-file (file)
16  (clnl:boot file))
17
18 (defun help (&optional token)
19  (format t
20   (if (not token)
21    "Placeholder help facility, try <:help :q> or <:help :load> for information about the commands we accept"
22    (case token
23     (:|:Q| ":q quits out of clnl")
24     (:|:LOAD|
25      (concatenate 'string
26       ":load <filename> loads up a model into the current clnl instance."
27       " Try :load \"Wolf Sheep Predation.nlogo\""))
28     (t (format nil "Don't have help for ~S" token))))))