       else if opts.print  then puts js
       else if opts.lint   then lint js
       else                     write_js source, coffee.compile code
-    compile_scripts()
+  catch err
+    if opts.watch then puts err.message else throw err
+
+# Watch a list of source CoffeeScript files, recompiling them every time the
+# files are updated.
+watch_scripts: ->
+  for source in sources
+    process.watchFile source, {persistent: true, interval: 500}, (curr, prev) ->
+      return if curr.mtime.getTime() is prev.mtime.getTime()
+      fs.cat(source).addCallback (code) -> compile_script(source, code)
+
 
 # Write out a JavaScript source file with the compiled code.
 write_js: (source, js) ->

  ['-i', '--interactive',   'run an interactive CoffeeScript REPL']
  ['-r', '--run',           'compile and run a CoffeeScript']
  ['-o', '--output [DIR]',  'set the directory for compiled JavaScript']
  # ['-w', '--watch',         'watch scripts for changes, and recompile']
  ['-p', '--print',         'print the compiled JavaScript to stdout']
  ['-l', '--lint',          'pipe the compiled JavaScript through JSLint']
  ['-e', '--eval',          'compile a string from the command line']


  paths: oparser.parse(process.ARGV)
  sources: paths[2...paths.length]

