def main(argv=None):
    """script main.
    parses command line options in sys.argv, unless *argv* is given.
    """

    if argv is None:
        argv = sys.argv

    # setup command line parser
    parser = E.OptionParser(version="%prog version: $Id$",
                            usage=globals()["__doc__"])

    parser.add_option(
        "--inplace", dest="inplace", action="store_true",
        help="update option list in place. New options will"
        "be added to the list given by --options-tsv-file. "
        "Options will only be added, not removed [%default]")

    parser.add_option(
        "--options-tsv-file", dest="tsv_file", type="string",
        help="existing table with options. Will be updated if "
        "--in-place is set [default]")

    parser.set_defaults(
        inplace=False,
        tsv_file=None)

    # add common options (-h/--help, ...) and parse command line
    (options, args) = E.Start(parser, argv=argv)

    old_options = None
    if options.tsv_file:
        if not os.path.exists(options.tsv_file):
            raise OSError(
                "filename %s not found, see --options-tsv-file" %
                options.tsv_file)
        old_options = pandas.read_csv(
            IOTools.openFile(options.tsv_file),
            sep="\t",
            index_col=0,
        )
        old_options = old_options.fillna("")

    global ORIGINAL_START
    ORIGINAL_START = E.Start

    all_options = collections.defaultdict(list)

    for label, expression in EXPRESSIONS:

        files = glob.glob(expression)
        files.sort()

        for f in files:

            E.debug("processing %s" % f)
            if os.path.isdir(f):
                continue
            if os.path.basename(f) in EXCLUDE:
                continue
            collected_options = collectOptionsFromScript(os.path.abspath(f))
            for o in collected_options:
                all_options[o].append(f)

    # add old options
    for x in old_options.index:
        if all_options not in x:
            all_options[x].append("--")

    if options.inplace:
        outfile = IOTools.openFile(options.tsv_file, "w")
        E.info("updating file '%s'" % options.tsv_file)
    else:
        outfile = options.stdout

    outfile.write("option\taction\tcomment\talternative\tfiles\n")
    for o, v in sorted(all_options.items()):
        try:
            action, comment, alternative, ff = old_options.xs(o)

        except KeyError:
            action, comment, alternative, ff = "", "", "", ""

        if comment == "nan":
            comment = ""
        if alternative == "nan":
            alternative = ""

        outfile.write("\t".join((map(
            str, (o, action, comment, alternative, ",".join(v))))) + "\n")

    if outfile != options.stdout:
        outfile.close()

    # write footer and output benchmark information.
    E.Stop()
dataset/ETHPy150Open CGATOxford/cgat/scripts/cgat_get_options.py/main/swapped operands of `not in`