Run Coffeescript Interactive (REPL) with a script
coffeescript, interactive, read-eval-print-loop
Solution
I've recently started a project to create an advanced interactive shell for Node and associated languages like CoffeeScript. One of the features is loading a file or string in the context of the interpreter at startup which takes into account the loaded language.
http://danielgtaylor.github.com/nesh/
Example:
# Load a string
nesh -c -e 'hello = (name) -> "Hello, #{name}"'
# Load a file
nesh -c -e hello.coffee
Then in the interpreter you can access the `hello` function. Also a good idea to create an alias in bash:
alias cs='nesh -c'
Problem
In python, I can run a script and enter interactive mode in the context of that script. This lets me mess with global variables and what not to examine program state. ``` $ python -i hello.py ``` Can I do this with Coffeescript? I've tried the following: ``` $ coffee -i hello.coffee ``` doesn't load hello.coffee. It's equivalent to coffee -i ``` $ cat hello.coffee | coffee -i ``` runs the script line by line in REPL but ends REPL after the EOF.