Skip to content

Commit

Permalink
print hashin's own version, fixes #41 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Bengtsson authored Jul 10, 2017
1 parent 469e16c commit e76911b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ put it directly into ``pip``.
Version History
===============

0.11.1
* Ability to run ``hashin --version`` to see what version of hashin is
installed.
See https://github.com/peterbe/hashin/issues/41

0.11.0
* Cope with leading zeros in version numbers when figuring out what
the latest version is.
Expand Down
14 changes: 14 additions & 0 deletions hashin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
action='append',
default=[],
)
parser.add_argument(
'--version',
help='Version of hashin',
action='store_true',
default=False,
)


major_pip_version = int(pip.__version__.split('.')[0])
if major_pip_version < 8:
Expand Down Expand Up @@ -408,6 +415,13 @@ def get_package_hashes(


def main():
if '--version' in sys.argv[1:]:
# Can't be part of argparse because the 'packages' is mandatory
# print out the version of self
import pkg_resources
print(pkg_resources.get_distribution('hashin').version)
return 0

args = parser.parse_args()

return run(
Expand Down
3 changes: 3 additions & 0 deletions tests/test_arg_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_everything():
python_version=['3.5'],
requirements_file='reqs.txt',
verbose=True,
version=False,
)
eq_(args, (expected, []))

Expand All @@ -37,6 +38,7 @@ def test_everything_long():
python_version=['3.5'],
requirements_file='reqs.txt',
verbose=True,
version=False,
)
eq_(args, (expected, []))

Expand All @@ -49,5 +51,6 @@ def test_minimal():
python_version=[],
requirements_file='requirements.txt',
verbose=False,
version=False,
)
eq_(args, (expected, []))

0 comments on commit e76911b

Please # to comment.