CLI Extension - Add load, help
[clnl] / src / main / extensions / cli / cli.lisp
index 84533918e1e49c6156f501a7f050d9348f927a2d..6d24da7fd941542af047f7054a6ebaa73a3ebc1d 100644 (file)
@@ -11,8 +11,25 @@ DESCRIPTION:
 
   PRIMS returns the primitives used in the CLI extension."
  (list
-  (list :name :q :type :command :func #'shut-down)))
+  (list :name :q :type :command :func #'shut-down)
+  (list :name :load :type :command :args '(t) :func #'load-file)
+  (list :name :help :type :command :args '((:token :optional)) :precedence 20 :func #'help)))
 
 (defun shut-down ()
  (cl-charms/low-level:endwin)
  (sb-ext:exit :abort t))
+
+(defun load-file (file)
+ (clnl:boot file))
+
+(defun help (&optional token)
+ (format t
+  (if (not token)
+   "Placeholder help facility, try <:help :q> or <:help :load> for information about the commands we accept"
+   (case token
+    (:|:Q| ":q quits out of clnl")
+    (:|:LOAD|
+     (concatenate 'string
+      ":load <filename> loads up a model into the current clnl instance."
+      " Try :load \"resources/models/Wolf Sheep Predation.nlogo\""))
+    (t (format nil "Don't have help for ~S" token))))))