From 230b0116f4d026d321d73a89edfb11134f356a18 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 16 Mar 2020 15:50:22 -0400 Subject: Quickfix for running without any commands Don't backtrace if there are no commands passed on cmdline. Reported-by: Jens Axboe Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 2 +- b4/command.py | 9 ++++++++- setup.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 203a0ed..c82fa35 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -19,7 +19,7 @@ from email import charset charset.add_charset('utf-8', None) emlpolicy = email.policy.EmailPolicy(utf8=True, cte_type='8bit', max_line_length=None) -VERSION = '0.3.1' +VERSION = '0.3.2' ATTESTATION_FORMAT_VER = '0.1' logger = logging.getLogger('b4') diff --git a/b4/command.py b/b4/command.py index 6830b92..9c2cbe9 100644 --- a/b4/command.py +++ b/b4/command.py @@ -8,6 +8,7 @@ __author__ = 'Konstantin Ryabitsev ' import argparse import logging import b4 +import sys logger = b4.logger @@ -49,8 +50,10 @@ def cmd_verify(cmdargs): def cmd(): parser = argparse.ArgumentParser( - formatter_class=argparse.ArgumentDefaultsHelpFormatter + description='A tool to work with public-inbox patches', + formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) + parser.add_argument('--version', action='version', version=b4.VERSION) parser.add_argument('-d', '--debug', action='store_true', default=False, help='Add more debugging info to the output') parser.add_argument('-q', '--quiet', action='store_true', default=False, @@ -122,6 +125,10 @@ def cmd(): logger.addHandler(ch) + if 'func' not in cmdargs: + parser.print_help() + sys.exit(1) + cmdargs.func(cmdargs) diff --git a/setup.py b/setup.py index 6a80bb2..1b9d769 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() -VERSION = '0.3.1' +VERSION = '0.3.2' NAME = 'b4' setup( -- cgit v1.2.3