Merge "Add --version option"

This commit is contained in:
Zuul 2019-08-30 07:20:19 +00:00 committed by Gerrit Code Review
commit 949a320cce
2 changed files with 9 additions and 1 deletions

View File

@ -14,4 +14,4 @@ import pbr.version
__version__ = pbr.version.VersionInfo(
'bashate').version_string()
'bashate').version_string_with_vcs()

View File

@ -22,6 +22,7 @@ import shlex
import subprocess
import sys
import bashate
from bashate import messages
MESSAGES = messages.MESSAGES
@ -431,9 +432,16 @@ def main(args=None):
parser.add_argument('-e', '--error',
help='Rules to always error (rather than warn)')
parser.add_argument('-v', '--verbose', action='store_true', default=False)
parser.add_argument('--version', action='store_true',
help='show bashate version number and exit',
default=False)
parser.add_argument('-s', '--show', action='store_true', default=False)
opts = parser.parse_args(args)
if opts.version:
print("bashate: %s" % bashate.__version__)
sys.exit(0)
if opts.show:
messages.print_messages()
sys.exit(0)