From a5cae3adb734ffdc9969ef1b6fc42eb41ffa26a6 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Sun, 17 Jul 2016 19:17:10 +0200 Subject: [PATCH] fix inconsistent behaviour of argparse-code this affected certain versions of argparse in python3 --- src/escpos/cli.py | 6 ++++++ 1 file changed, 6 insertions(+) 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)