Add --version option

This commit adds ``--version`` option for the command line.

Change-Id: I8dee5fa2154dd083a04204c33989e6ee318046a6
This commit is contained in:
Masayuki Igawa 2019-06-27 15:02:14 +09:00
parent 0e90a6d7a3
commit 6a787ca764
No known key found for this signature in database
GPG Key ID: 290F53EDC899BF89
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)