diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-16 15:50:22 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-16 15:50:22 -0400 |
commit | 230b0116f4d026d321d73a89edfb11134f356a18 (patch) | |
tree | 622db2c4c1ebc00b74c6ada22ece325c2c0f6f27 | |
parent | 73ced909545d3fca2679efd9a4eca7f69b36150b (diff) | |
download | b4-230b0116f4d026d321d73a89edfb11134f356a18.tar.gz |
Quickfix for running without any commandsv0.3.2
Don't backtrace if there are no commands passed on cmdline.
Reported-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 2 | ||||
-rw-r--r-- | b4/command.py | 9 | ||||
-rw-r--r-- | 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 <konstantin@linuxfoundation.org>' 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) @@ -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( |