def main():
parser = argparse.ArgumentParser(<EOL>description='<STR_LIT>',<EOL>epilog='<STR_LIT>'<EOL>'<STR_LIT>',<EOL>)<EOL>parser.register('<STR_LIT:type>', '<STR_LIT:bool>', str_to_bool)<EOL>parser.add_argument(<EOL>'<STR_LIT:-c>', '<STR_LIT>',<EOL>help='<STR_LIT>',<EOL>)<EOL>command_subparsers = parser.add_subparsers(<EOL>title='<STR_LIT>',<EOL>dest='<STR_LIT>',<EOL>)<EOL>command_subparsers.required = False   <EOL>for command in ESCPOS_COMMANDS:<EOL><INDENT>parser_command = command_subparsers.add_parser(**command['<STR_LIT>'])<EOL>parser_command.set_defaults(**command['<STR_LIT>'])<EOL>for argument in command['<STR_LIT>']:<EOL><INDENT>option_strings = argument.pop('<STR_LIT>')<EOL>parser_command.add_argument(*option_strings, **argument)<EOL><DEDENT><DEDENT>parser_command_demo = command_subparsers.add_parser('<STR_LIT>',<EOL>help='<STR_LIT>')<EOL>parser_command_demo.set_defaults(func='<STR_LIT>')<EOL>demo_group = parser_command_demo.add_mutually_exclusive_group()<EOL>demo_group.add_argument(<EOL>'<STR_LIT>',<EOL>help='<STR_LIT>',<EOL>action='<STR_LIT:store_true>',<EOL>)<EOL>demo_group.add_argument(<EOL>'<STR_LIT>',<EOL>help='<STR_LIT>',<EOL>action='<STR_LIT:store_true>',<EOL>)<EOL>demo_group.add_argument(<EOL>'<STR_LIT>',<EOL>help='<STR_LIT>',<EOL>action='<STR_LIT:store_true>',<EOL>)<EOL>demo_group.add_argument(<EOL>'<STR_LIT>',<EOL>help='<STR_LIT>',<EOL>action='<STR_LIT:store_true>',<EOL>)<EOL>parser_command_version = command_subparsers.add_parser('<STR_LIT:version>',<EOL>help='<STR_LIT>')<EOL>parser_command_version.set_defaults(version=True)<EOL>if '<STR_LIT>' in globals():<EOL><INDENT>argcomplete.autocomplete(parser)<EOL><DEDENT>args_dict = vars(parser.parse_args())<EOL>if not args_dict:<EOL><INDENT>parser.print_help()<EOL>sys.exit()<EOL><DEDENT>command_arguments = dict([k, v] for k, v in six.iteritems(args_dict) if v is not None)<EOL>print_version = command_arguments.pop('<STR_LIT:version>', None)<EOL>if print_version:<EOL><INDENT>print(version.version)<EOL>sys.exit()<EOL><DEDENT>config_path = command_arguments.pop('<STR_LIT>', None)<EOL>saved_config = config.Config()<EOL>saved_config.load(config_path)<EOL>printer = saved_config.printer()<EOL>if not printer:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>target_command = command_arguments.pop('<STR_LIT>')<EOL>command_arguments.pop('<STR_LIT>', None)<EOL>if hasattr(printer, target_command):<EOL><INDENT>getattr(printer, target_command)(**command_arguments)<EOL>if target_command in REQUIRES_NEWLINE:<EOL><INDENT>printer.text("<STR_LIT:\n>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>command_arguments['<STR_LIT>'] = printer<EOL>globals()[target_command](**command_arguments)<EOL><DEDENT>
Handles loading of configuration and creating and processing of command
line arguments. Called when run from a CLI.