         when "j", "jump"  then jumpCommand param
         when "b", "break" then breakCommand param
         when "x", "exec"  then execCommand param
+        when "r", "reset" then resetCommand param
         when "q", "quit"  then quitCommand param
-        else stdout.write "Type 'help' to print available commands.\n"
+        else print "Type 'help' to print available commands."
     rl.prompt()
 
 rl.on "close", ->
-    stdout.write "\n"
-    process.exit 0
+    quitCommand()

nes = injector.getInstance "nes"
nes.insertCartridge cartridge

stdin = process.stdin
stdout = process.stdout

###########################################################
# Commands

                .replace /.*\[Function\].*\n/g, ""
        else if typeof result is "number"
            result = "0x#{numberAsHex result}"
        print "#{param} = #{result}"
    catch error
        print "Error: #{error.message}"

resetCommand = (param) ->
    nes.pressReset()

quitCommand = (param) ->
    process.exit 0
