def main(argv=None):
  """Main function.

  Args:
    argv: Sequence of command line arguments.
  """
  if argv is None:
    argv = flags.FLAGS(sys.argv)

  if FLAGS.time:
    start_time = time.time()

  # Emacs sets the environment variable INSIDE_EMACS in the subshell.
  # Request Unix mode as emacs will expect output to be in Unix format
  # for integration.
  # See https://www.gnu.org/software/emacs/manual/html_node/emacs/
  # Interactive-Shell.html
  if 'INSIDE_EMACS' in os.environ:
    FLAGS.unix_mode = True

  suffixes = ['.js']
  if FLAGS.additional_extensions:
    suffixes += ['.%s' % ext for ext in FLAGS.additional_extensions]
  if FLAGS.check_html:
    suffixes += ['.html', '.htm']
  paths = fileflags.GetFileList(argv, 'JavaScript', suffixes)

  if FLAGS.multiprocess:
    records_iter = _MultiprocessCheckPaths(paths)
  else:
    records_iter = _CheckPaths(paths)

  records_iter, records_iter_copy = itertools.tee(records_iter, 2)
  _PrintErrorRecords(records_iter_copy)

  error_records = list(records_iter)
  _PrintSummary(paths, error_records)

  exit_code = 0

  # If there are any errors
  if error_records:
    exit_code += 1

  # If there are any new errors
  if [r for r in error_records if r.new_error]:
    exit_code += 2

  if exit_code:
    if FLAGS.summary:
      _PrintFileSummary(paths, error_records)

    if FLAGS.beep:
      # Make a beep noise.
      sys.stdout.write(chr(7))

    # Write out instructions for using fixjsstyle script to fix some of the
    # reported errors.
    fix_args = []
    for flag in sys.argv[1:]:
      for f in GJSLINT_ONLY_FLAGS:
        if flag.startswith(f):
          break
      else:
        fix_args.append(flag)

    if not FLAGS.quiet:
      print """
Some of the errors reported by GJsLint may be auto-fixable using the script
fixjsstyle. Please double check any changes it makes and report any bugs. The
script can be run by executing:

fixjsstyle %s """ % ' '.join(fix_args)

  if FLAGS.time:
    print 'Done in %s.' % _FormatTime(time.time() - start_time)

  sys.exit(exit_code)
dataset/ETHPy150Open google/closure-linter/closure_linter/gjslint.py/main/original