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>if args['<STR_LIT>']:<EOL><INDENT>ignore = args['<STR_LIT>'].split('<STR_LIT:U+002C>')<EOL><DEDENT>else:<EOL><INDENT>ignore = []<EOL><DEDENT>command = next((c for c in ALL_COMMANDS if args[c] is True), None)<EOL>if command:<EOL><INDENT>protocol = PROTOCOLS['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>protocol = PROTOCOLS[args['<STR_LIT>']]<EOL><DEDENT>conn = create_rflink_connection(<EOL>protocol=protocol,<EOL>host=args['<STR_LIT>'],<EOL>port=args['<STR_LIT>'],<EOL>baud=args['<STR_LIT>'],<EOL>loop=loop,<EOL>ignore=ignore,<EOL>)<EOL>transport, protocol = loop.run_until_complete(conn)<EOL>try:<EOL><INDENT>if command:<EOL><INDENT>for _ in range(int(args['<STR_LIT>'])):<EOL><INDENT>loop.run_until_complete(<EOL>protocol.send_command_ack(<EOL>args['<STR_LIT>'], command))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>loop.run_forever()<EOL><DEDENT><DEDENT>except KeyboardInterrupt:<EOL><INDENT>transport.close()<EOL>loop.run_forever()<EOL><DEDENT>finally:<EOL><INDENT>loop.close()<EOL><DEDENT>
Parse argument and setup main program loop.