   }
   fileList = argv._
 
-  return version() if argv.version
-  return help() if argv.help or argv._.length is 0
+  if argv.version then return version()
+  if argv.help or (argv._.length is 0 and typeof argv.drill isnt 'string')
+    return help()
 
   # console
   warn = (string) -> console.error chalk.bold.yellow string unless argv.quiet

  Usage: gerber2svg [options] path/to/gerbers
  Output:
    `gerber2svg path/to/gerber.gbr` will write the svg to stdout
    `gerber2svg path/to/gerber.gbr -o some/dir` will create some/dir/gerber.svg
'''

OPTIONS = [
  [ 'o', 'out', '     specify an output directory' ]
  [ 'q', 'quiet', '   run quietly (does not include svg output)' ]
  [ 'v', 'version', ' display version information' ]
  [ 'h', 'help', '    display this help text' ]
]

  write = (string, filename) ->
    unless argv.out then process.stdout.write string
    else
      if argv.append then newName = path.basename filename
      else newName = path.basename filename, path.extname filename
      newName = path.join argv.out, newName + '.svg'
      fs.writeFile newName, string, (error) ->
        unless error then print "#{filename} converted to #{newName}"
        else warn "Error writing to #{newName}: #{error.code}"

  # add drill file if it was included
  if argv.drill? and not argv.drill in fileList then fileList.push argv.drill
  # loop through files
  for file in fileList
    do (file) ->
      fs.readFile file, 'utf-8', (error, data) ->
        unless error
          try
            opts = { pretty: argv.pretty, drill: (file is argv.drill) }
            write gerberToSvg(data, opts), file
          catch e
            warn "could not process #{file}: #{e.message}"
        else
          warn "Error reading file #{file}: #{error.code}"

module.exports = run
