def main(argv=sys.argv[<NUM_LIT:1>:], loop=None):
args = docopt(__doc__, argv=argv,<EOL>version=pkg_resources.require('<STR_LIT>')[<NUM_LIT:0>].version)<EOL>level = logging.ERROR<EOL>if args['<STR_LIT>']:<EOL><INDENT>level = logging.INFO<EOL><DEDENT>if args['<STR_LIT>'] == <NUM_LIT:2>:<EOL><INDENT>level = logging.DEBUG<EOL><DEDENT>logging.basicConfig(level=level)<EOL>if not loop:<EOL><INDENT>loop = asyncio.get_event_loop()<EOL><DEDENT>host = args['<STR_LIT>']<EOL>port = args['<STR_LIT>']<EOL>baud = args['<STR_LIT>']<EOL>listenport = args['<STR_LIT>']<EOL>proxy = RFLinkProxy(port=port, host=host, baud=baud, loop=loop)<EOL>server_coro = asyncio.start_server(<EOL>proxy.client_connected_callback,<EOL>host="<STR_LIT>",<EOL>port=listenport,<EOL>loop=loop,<EOL>)<EOL>server = loop.run_until_complete(server_coro)<EOL>addr = server.sockets[<NUM_LIT:0>].getsockname()<EOL>log.info('<STR_LIT>', addr)<EOL>conn_coro = proxy.connect()<EOL>loop.run_until_complete(conn_coro)<EOL>proxy.closing = False<EOL>try:<EOL><INDENT>loop.run_forever()<EOL><DEDENT>except KeyboardInterrupt:<EOL><INDENT>proxy.closing = True<EOL>server.close()<EOL>loop.run_until_complete(server.wait_closed())<EOL>writers = [i[<NUM_LIT:1>] for i in list(clients)]<EOL>for writer in writers:<EOL><INDENT>writer.close()<EOL>if sys.version_info >= (<NUM_LIT:3>, <NUM_LIT:7>):<EOL><INDENT>loop.run_until_complete(writer.wait_closed())<EOL><DEDENT><DEDENT>proxy.transport.close()<EOL><DEDENT>finally:<EOL><INDENT>loop.close()<EOL><DEDENT>
Parse argument and setup main program loop.