diff --git a/src/escpos/cli.py b/src/escpos/cli.py index 7dc7287..5457df5 100644 --- a/src/escpos/cli.py +++ b/src/escpos/cli.py @@ -456,7 +456,10 @@ def main(): # cli [subparser] -args command_subparsers = parser.add_subparsers( title='ESCPOS Command', + dest='parser', ) + # fix inconsistencies in the behaviour of some versions of argparse + command_subparsers.required = False # force 'required' testing # Build the ESCPOS command arguments for command in ESCPOS_COMMANDS: @@ -522,6 +525,9 @@ def main(): target_command = command_arguments.pop('func') + # remove helper-argument 'parser' from dict + command_arguments.pop('parser', None) + if hasattr(printer, target_command): # print command with args getattr(printer, target_command)(**command_arguments)