File: custom_repl.coffee

package info (click to toggle)
coffeescript 1.10.0~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,292 kB
  • sloc: makefile: 62
file content (20 lines) | stat: -rw-r--r-- 542 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
###
Example of embedding the CoffeeScript REPL, strikingly similar to the Node REPL.
###

# Require 'coffee-script/repl' to import the repl module
repl = require '../repl'

console.log 'Custom REPL! Type `sayHi()` to see what it does!'

# Start the REPL with your configuration
r = repl.start
  prompt: 'my-repl> '

# Fields added to the context object are exposed as variables in the REPL
r.context.sayHi = -> console.log 'Hello'

# An exit event is emitted when the user exits the REPL
r.on 'exit', ->
  console.log 'Bye!'
  process.exit()