From 92fae8cd60b7c5a66098d6e6044803c4a8a8c17a Mon Sep 17 00:00:00 2001 From: Frank Duncan Date: Sun, 15 May 2016 12:19:38 -0500 Subject: [PATCH] CLI Extension - Add load, help --- src/main/cli.lisp | 2 +- src/main/extensions/cli/cli.lisp | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/cli.lisp b/src/main/cli.lisp index 1aeb746..4dcc8f0 100644 --- a/src/main/cli.lisp +++ b/src/main/cli.lisp @@ -31,7 +31,7 @@ DESCRIPTION: (handler-case (with-output-to-string (*standard-output*) (clnl:run-commands str)) - (error (e) (format nil "Ok, something went wrong: ~A" e)))) + (error (e) (format nil "Ok, something went wrong: ~A~%Try :help" e)))) ; for ui, we need to do at a minimum: ; - cli, first pass, read things in, bottom of the screen, diff --git a/src/main/extensions/cli/cli.lisp b/src/main/extensions/cli/cli.lisp index 8453391..6d24da7 100644 --- a/src/main/extensions/cli/cli.lisp +++ b/src/main/extensions/cli/cli.lisp @@ -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 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)))))) -- 2.25.1