From 4f92247ed6ded06aee06861f28d5eb0ad70caad7 Mon Sep 17 00:00:00 2001 From: Davis Goglin Date: Wed, 16 Mar 2016 16:21:05 -0700 Subject: [PATCH] Fix no help display in python3 --- escpos/cli.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/escpos/cli.py b/escpos/cli.py index 5dcda69..12e2aa1 100755 --- a/escpos/cli.py +++ b/escpos/cli.py @@ -3,6 +3,7 @@ from __future__ import absolute_import import argparse +import sys import six from . import config @@ -308,12 +309,16 @@ def main(): action='store_true', ) + # Get only arguments actually passed + args_dict = vars(parser.parse_args()) + if not args_dict: + parser.print_help() + sys.exit() + command_arguments = dict([k, v] for k, v in six.iteritems(args_dict) if v) + if not printer: raise Exception('No printers loaded from config') - # Get only arguments actually passed - args_dict = vars(parser.parse_args()) - command_arguments = dict([k, v] for k, v in six.iteritems(args_dict) if v) target_command = command_arguments.pop('func')