<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def main():
 """The main entry point of the program"""


    # Parse command line arguments
    argp = _cli_argument_parser()
    args = argp.parse_args()

    # setup logging
    logging.basicConfig(
        level=args.loglevel,
        format="%(levelname)s %(message)s")

    console.display("Collecting documentation from files")
    collector_metrics = metrics.Metrics()
    docs = collector.parse(args.path, args.trace_parser,
                           metrics=collector_metrics)
    collector_metrics.display()

    console.display("Rendering documentation")

    try:
        if args.output:
            template = renderer.template_from_filename(args.output)
        else:
            template = "json"
        out = renderer.render(docs, template)
    except ValueError as err:
        logging.error(err)
        sys.exit(1)
    except TemplateNotFound as err:
        logging.error(
            "Template `{}` not found. Available templates are: {}".format(
                err.name, renderer.list_templates()))
        sys.exit(1)

    if not args.output:
        print(out)
    else:
        console.display("Writing documentation to", args.output)
        with io.open(args.output, "w", encoding="utf-8") as fp:
            fp.write(out)