Skip to content

Instantly share code, notes, and snippets.

@paniq
Last active November 26, 2019 22:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paniq/f15f6ab62ea607f647f4c4a184d10758 to your computer and use it in GitHub Desktop.
Save paniq/f15f6ab62ea607f647f4c4a184d10758 to your computer and use it in GitHub Desktop.
#!/usr/bin/env scopes
using import console
#using import ...conspire.module
let source-path argc argv = (script-launch-args)
# transform command line to symbolic list
let cmd =
fold (cmd = '()) for i in (rrange 0 argc)
let arg = (argv @ i)
let str = (string arg)
let val =
if (i == 0) `[(Symbol str)]
else `str
cons val cmd
# build scope with which we're going to evaluate commands
let repl-scope =
do
inline test-repl ()
print "REPL active"
# must keep sugar support
indirect-let list-handler-symbol
locals;
let scope =
repl-scope
# use the line below to prepend your symbols to existing globals
#.. repl-scope
globals;
# if no shell command has been issued, enter REPL console
if (cmd == '())
print "Conspire REPL"
read-eval-print-loop scope false
.. cache-dir "/conspire.history"
exit 0
# otherwise evaluate command (which includes compilation)
let f =
try
sc_eval unknown-anchor (list cmd) scope
except (err)
print
'format err
exit -1
run-stage;
# and execute it in the next stage
f;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment