From 3623151b5bdfd2efe60123de11207335bbc9d16d Mon Sep 17 00:00:00 2001 From: Jeremiah C Leary Date: Fri, 28 Jun 2019 07:48:37 -0500 Subject: [PATCH] Updates for issue #246 1) Added version argument to display version. 2) Refactored version information to reside in a single file. a) setup.py references this file b) conf.py references this file c) version argument references this file --- docs/conf.py | 5 +++-- setup.py | 4 +++- vsg/__main__.py | 4 ++++ vsg/version.py | 8 ++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 vsg/version.py diff --git a/docs/conf.py b/docs/conf.py index 926155be..6f09e078 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,6 +20,7 @@ import os import sys sys.path.insert(0, os.path.abspath('..')) +import vsg.version # -- General configuration ------------------------------------------------ @@ -54,9 +55,9 @@ author = u'Jeremiah C Leary' # built documents. # # The short X.Y version. -version = u'0.38' +version = str(vsg.version.version) # The full version, including alpha/beta/rc tags. -release = u'0.38' +release = str(vsg.version.version) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index f70bc53e..754a1819 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,8 @@ from setuptools import setup from setuptools import find_packages +from vsg import version + def readme(): with open('README.rst') as f: return f.read() @@ -9,7 +11,7 @@ def readme(): setup( name='vsg', - version='0.38', + version=str(version.version), description='VHDL Style Guide', long_description=readme(), classifiers=[ diff --git a/vsg/__main__.py b/vsg/__main__.py index f07cb3bb..bc88c0e1 100644 --- a/vsg/__main__.py +++ b/vsg/__main__.py @@ -11,6 +11,7 @@ import yaml from . import rule_list from . import vhdlFile from . import junit +from . import version def parse_command_line_arguments(): @@ -31,6 +32,7 @@ def parse_command_line_arguments(): parser.add_argument('-of', '--output_format', action='store', default='vsg', choices=['vsg', 'syntastic'], help='Sets the output format.') parser.add_argument('-b', '--backup', default=False, action='store_true', help='Creates copy of input file for comparison with fixed version.') parser.add_argument('-oc', '--output_configuration', default=None, action='store', help='Output configuration file name') + parser.add_argument('-v', '--version', default=False, action='store_true', help='Displays version information') if len(sys.argv) == 1: parser.print_help() @@ -147,6 +149,8 @@ def main(): commandLineArguments = parse_command_line_arguments() + version.print_version(commandLineArguments) + configuration = read_configuration_files(commandLineArguments) update_command_line_arguments(commandLineArguments, configuration) diff --git a/vsg/version.py b/vsg/version.py new file mode 100644 index 00000000..5dc7d18f --- /dev/null +++ b/vsg/version.py @@ -0,0 +1,8 @@ +version = 0.39 + + +def print_version(oCommandLineArguments): + + if (oCommandLineArguments.version): + print('VHDL Style Guide (VSG) version ' + str(version)) + exit(0)