def main():
    argv = sys.argv[1:]
    try:
        (opts, args) = getopt.getopt(argv, 's:c:o:dEPjbkil:xhtfvXw:', ['indent-size=', 'indent-char=', 'outfile=', 'disable-preserve-newlines', 'space-in-paren', 'space-in-empty-paren', 'jslint-happy', 'brace-style=', 'keep-array-indentation', 'indent-level=', 'unescape-strings', 'help', 'usage', 'stdin', 'eval-code', 'indent-with-tabs', 'keep-function-indentation', 'version', 'e4x', 'wrap-line-length'])
    except getopt.GetoptError as ex:
        print(ex, file=sys.stderr)
        return usage(sys.stderr)
    js_options = default_options()
    file = None
    outfile = 'stdout'
    if (len(args) == 1):
        file = args[0]
    for (opt, arg) in opts:
        if (opt in ('--keep-array-indentation', '-k')):
            js_options.keep_array_indentation = True
        if (opt in ('--keep-function-indentation', '-f')):
            js_options.keep_function_indentation = True
        elif (opt in ('--outfile', '-o')):
            outfile = arg
        elif (opt in ('--indent-size', '-s')):
            js_options.indent_size = int(arg)
        elif (opt in ('--indent-char', '-c')):
            js_options.indent_char = arg
        elif (opt in ('--indent-with-tabs', '-t')):
            js_options.indent_with_tabs = True
        elif (opt in ('--disable-preserve-newlines', '-d')):
            js_options.preserve_newlines = False
        elif (opt in ('--space-in-paren', '-P')):
            js_options.space_in_paren = True
        elif (opt in ('--space-in-empty-paren', '-E')):
            js_options.space_in_empty_paren = True
        elif (opt in ('--jslint-happy', '-j')):
            js_options.jslint_happy = True
        elif (opt in '--eval-code'):
            js_options.eval_code = True
        elif (opt in ('--brace-style', '-b')):
            js_options.brace_style = arg
        elif (opt in ('--unescape-strings', '-x')):
            js_options.unescape_strings = True
        elif (opt in ('--e4x', '-X')):
            js_options.e4x = True
        elif (opt in ('--wrap-line-length ', '-w')):
            js_options.wrap_line_length = int(arg)
        elif (opt in ('--stdin', '-i')):
            file = '-'
        elif (opt in ('--version', '-v')):
            return print(__version__)
        elif (opt in ('--help', '--usage', '-h')):
            return usage()
    if (not file):
        print('Must define at least one file.', file=sys.stderr)
        return usage(sys.stderr)
    else:
        try:
            if (outfile == 'stdout'):
                print(beautify_file(file, js_options))
            else:
                mkdir_p(os.path.dirname(outfile))
                with open(outfile, 'w') as f:
                    f.write((beautify_file(file, js_options) + '\n'))
        except Exception as ex:
            print(ex, file=sys.stderr)
            return 1
    return 0
def main():
    argv = sys.argv[1:]
    try:
        (opts, args) = getopt.getopt(argv, 's:c:o:dEPjbkil:xhtfvXw:', ['indent-size=', 'indent-char=', 'outfile=', 'disable-preserve-newlines', 'space-in-paren', 'space-in-empty-paren', 'jslint-happy', 'brace-style=', 'keep-array-indentation', 'indent-level=', 'unescape-strings', 'help', 'usage', 'stdin', 'eval-code', 'indent-with-tabs', 'keep-function-indentation', 'version', 'e4x', 'wrap-line-length'])
    except getopt.GetoptError as ex:
        print(ex, file=sys.stderr)
        return usage(sys.stderr)
    js_options = default_options()
    file = None
    outfile = 'stdout'
    if (len(args) == 1):
        file = args[0]
    for (opt, arg) in opts:
        if (opt in ('--keep-array-indentation', '-k')):
            js_options.keep_array_indentation = True
        if (opt in ('--keep-function-indentation', '-f')):
            js_options.keep_function_indentation = True
        elif (opt in ('--outfile', '-o')):
            outfile = arg
        elif (opt in ('--indent-size', '-s')):
            js_options.indent_size = int(arg)
        elif (opt in ('--indent-char', '-c')):
            js_options.indent_char = arg
        elif (opt in ('--indent-with-tabs', '-t')):
            js_options.indent_with_tabs = True
        elif (opt in ('--disable-preserve-newlines', '-d')):
            js_options.preserve_newlines = False
        elif (opt in ('--space-in-paren', '-P')):
            js_options.space_in_paren = True
        elif (opt in ('--space-in-empty-paren', '-E')):
            js_options.space_in_empty_paren = True
        elif (opt in ('--jslint-happy', '-j')):
            js_options.jslint_happy = True
        elif (opt in '--eval-code'):
            js_options.eval_code = True
        elif (opt in ('--brace-style', '-b')):
            js_options.brace_style = arg
        elif (opt in ('--unescape-strings', '-x')):
            js_options.unescape_strings = True
        elif (opt in ('--e4x', '-X')):
            js_options.e4x = True
        elif (opt in ('--wrap-line-length ', '-w')):
            js_options.wrap_line_length = int(arg)
        elif (opt in ('--stdin', '-i')):
            file = '-'
        elif (opt in ('--version', '-v')):
            return print(__version__)
        elif (opt in ('--help', '--usage', '-h')):
            return usage()
    if (not file):
        print('Must define at least one file.', file=sys.stderr)
        return usage(sys.stderr)
    else:
        try:
            if (outfile == 'stdout'):
                print(beautify_file(file, js_options))
            else:
                mkdir_p(os.path.dirname(outfile))
                with open(outfile, 'w') as f:
                    f.write((beautify_file(file, js_options) + '\n'))
        except Exception as ex:
            print(ex, file=sys.stderr)
            return 1
    return 0