def main(config, args):
    description = "Interact with testplan objects."
    m = re.match(r'^.*\.(.*)$', __name__)
    controller_name = m.groups()[0]
    del sys.argv[1]
    parser = argparse.ArgumentParser(prog="%s %s" % (sys.argv[0], controller_name), description=description)
    subparsers = parser.add_subparsers(dest="action")

    # create
    create_parser = subparsers.add_parser("create", help="create testplan object")
    create_parser_required = create_parser.add_argument_group("required arguments")
    create_parser_required.add_argument("--name", type=str, required=True)
    create_parser.add_argument("--description", type=str)

    # read
    read_parser = subparsers.add_parser("read", help="read testplan object(s)")
    read_parser.add_argument("--all", action="store_const", const=True, default=False, help="read all testplans")
    read_parser.add_argument("--testplan", type=str, help="ID of testplan to read")

    # update
    update_parser = subparsers.add_parser("update", help="update existing testplan object")
    update_parser_required = update_parser.add_argument_group("required arguments")
    update_parser_required.add_argument("--testplan", type=str, required=True, help="testplan id to update")
    update_parser.add_argument("--name", type=str)
    update_parser.add_argument("--description", type=str)

    # delete
    delete_parser = subparsers.add_parser("delete", help="delete testplan object")
    delete_parser_required = delete_parser.add_argument_group("required arguments")
    delete_parser_required.add_argument("--testplan", type=str, required=True, help="testplan id to delete")

    args = vars(parser.parse_args())
    action_map = {
        "create": create,
        "read": read,
        "update": update,
        "delete": delete,
    }
    action_map[args['action']](config, args)
dataset/ETHPy150Open emccode/heliosburn/heliosburn/hbcli/controllers/testplan.py/main/original