   # Parse the opts, with a possible input override.
   opts = nomnom.parse input
   
-  for file in opts.files
+  # If the user specified coffee usage, import immediately.
+  if opts.coffee is true
+    import_coffee()
+  
+  for user_file in opts.files
     # Resolve the path relative to the cwd.
-    file = path.join process.cwd(), file
+    file = path.join process.cwd(), user_file
+    
+    # Check if the file specified by the user even exists.
+    if not existsSync(file)
+      # Compensate for user shorthand.
+      if path.extname(file) is '' and existsSync "#{file}.js"
+          file = "#{file}.js"
+      else if path.extname(file) is '' and existsSync "#{file}.coffee"
+          file = "#{file}.coffee"
+      else
+        throw new Error "The file '#{user_file}' does not exist."
+    
+    # If the user didn't specify a coffee option, attempt to figure
+    # out if the file is CoffeeScript. The below code also supports
+    # specifying a directory with a coffee index file.
+    if opts.coffee is undefined
+      stat = fs.statSync file
+      if stat.isFile() and path.extname(file) is '.coffee'
+        import_coffee()
+      else if stat.isDirectory()
+        # We aren't catching the error here, because we don't care.
+        # If the filename we made up doesn't exist, move on.
+        try
+          index_file = path.join file, 'index.coffee'
+          stat = fs.statSync index_file
+          if path.extname(index_file) is '.coffee'
+            import_coffee()
+    
     
     # Import the target file/directory, then simply run dork.
     # All tests within the given file "should" (lol) have defined themselves

nomnom.help 'Start dork tests in the given file or directory with '+
  'optional overriding options.'
nomnom.options
  files:
    default: ['./test']
    abbr: 'f'

    dork.run()


# Desc:
#   A simple function to attempt to import coffee, or fail with a meaningful
#   message if coffee is not found.
import_coffee = ->
  try
    require 'coffee-script'
  catch e
    if e.message is "Cannot find module 'coffee-script'"
      throw new Error 'CoffeeScript must be installed manually to test '+
        '.coffee files.'
    else
      throw e




exports.exec = exec