Skip to content

Commit

Permalink
Add command line options to show version number
Browse files Browse the repository at this point in the history
Add -V command line option (and --version as an alias) to
both wireviz.py and build_examples.py that show version number.

Move the version number from setup.py into __init__.py to access
the same version number specification from all files needing it.

This solves part 4 of issue #167.
  • Loading branch information
kvid authored and formatc1702 committed Oct 11, 2020
1 parent c4957f1 commit 7df8a4b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import os
from setuptools import setup, find_packages

from src.wireviz import __version__

project_name = 'wireviz'

# Utility function to read the README file.
Expand All @@ -15,7 +17,7 @@ def read(fname):

setup(
name=project_name,
version='0.1',
version=__version__,
author='Daniel Rojas',
#author_email='',
description='Easily document cables and wiring harnesses',
Expand Down
3 changes: 3 additions & 0 deletions src/wireviz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please don't import anything in this file to avoid issues when it is imported in setup.py

__version__ = '0.1.1'
3 changes: 2 additions & 1 deletion src/wireviz/build_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
script_path = Path(__file__).absolute()

sys.path.insert(0, str(script_path.parent.parent)) # to find wireviz module
from wireviz import wireviz
from wireviz import wireviz, __version__
from wv_helper import open_file_write, open_file_read, open_file_append


Expand Down Expand Up @@ -128,6 +128,7 @@ def restore_generated(groupkeys, branch = ''):

def parse_args():
parser = argparse.ArgumentParser(description='Wireviz Example Manager',)
parser.add_argument('-V', '--version', action='version', version='%(prog)s - wireviz ' + __version__)
parser.add_argument('action', nargs='?', action='store',
choices=['build','clean','compare','diff','restore'], default='build',
help='what to do with the generated files (default: build)')
Expand Down
3 changes: 2 additions & 1 deletion src/wireviz/wireviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
if __name__ == '__main__':
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))


from wireviz import __version__
from wireviz.Harness import Harness
from wireviz.wv_helper import expand, open_file_read

Expand Down Expand Up @@ -211,6 +211,7 @@ def parse_cmdline():
parser = argparse.ArgumentParser(
description='Generate cable and wiring harness documentation from YAML descriptions',
)
parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + __version__)
parser.add_argument('input_file', action='store', type=str, metavar='YAML_FILE')
parser.add_argument('-o', '--output_file', action='store', type=str, metavar='OUTPUT')
# Not implemented: parser.add_argument('--generate-bom', action='store_true', default=True)
Expand Down

0 comments on commit 7df8a4b

Please sign in to comment.