aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-23 15:36:09 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-23 15:36:09 -0800
commit113b916e4ca179aded05d25a2d0d4f24b4f053c6 (patch)
tree121d6d99a24334e46e22bd99e040decb30f65146
parent967f172094c435139f9e1af14ebfb049670c34f2 (diff)
Fixed to display expressions by default.
-rwxr-xr-xlib/tools/repl.nom42
1 files changed, 23 insertions, 19 deletions
diff --git a/lib/tools/repl.nom b/lib/tools/repl.nom
index ea0cc8a..3d2318c 100755
--- a/lib/tools/repl.nom
+++ b/lib/tools/repl.nom
@@ -16,15 +16,32 @@ external:
To exit, type 'exit' or 'quit' and hit enter twice.
")
+ (tutorial) means:
+ (use "tools/tutorial").run_with {.extras = []}
+ exit
+
command line program with $args:
say ("
\(bright)\(underscore)Welcome to the Nomsu v\(Nomsu version) interactive console!\
..\(reset color)
press 'enter' twice to run a command
+ type 'tutorial' to run the tutorial
")
-
+
+ # Best way I know of to detect the number of return values and only
+ print if it's >0:
+ (say results of (*extra arguments*)) means:
+ $N = (select "#" (*extra arguments*))
+ if ($N == 0):
+ return
+ for $ in 1 to $N:
+ $ret = (select $ (*extra arguments*))
+ if ($ret is "Text"):
+ $ret = (quote $ret)
+ say "\$ret"
+
repeat:
say (bright (yellow ">> ")) inline
$buff = []
@@ -51,7 +68,7 @@ command line program with $args:
unless $tree:
do next
-
+
for $chunk in $tree:
try:
$lua = ($chunk as lua)
@@ -64,22 +81,9 @@ command line program with $args:
so that stuff mostly works across multiple lines. It would be
nicer if local variables actually worked.
$lua, remove free vars
+ if (load "return \($lua, text)"):
+ $lua, prepend "return "
+
try:
- $ret = (run $lua)
+ say results of (run $lua)
..if it fails with $err: say $err
- ..if it succeeds:
- if (lua type of $ret) is:
- "nil":
- do nothing
-
- "boolean":
- say "= \("yes" if $ret else "no")"
-
- "table":
- if $ret.as_nomsu:
- say "= \($ret, as nomsu)"
- ..else:
- say "= \$ret"
-
- else:
- say "= \$ret"