Commit 72cceb15 authored by Marius Gedminas's avatar Marius Gedminas

Add bin/buildout --version

Fixes https://bugs.launchpad.net/zc.buildout/+bug/309770
parent e1194b1e
...@@ -1601,6 +1601,10 @@ Options: ...@@ -1601,6 +1601,10 @@ Options:
Print this message and exit. Print this message and exit.
--version
Print buildout version number and exit.
-v -v
Increase the level of verbosity. This option can be used multiple times. Increase the level of verbosity. This option can be used multiple times.
...@@ -1706,10 +1710,17 @@ Commands: ...@@ -1706,10 +1710,17 @@ Commands:
COMPUTED_VALUE, DEFAULT_VALUE, COMMAND_LINE_VALUE). COMPUTED_VALUE, DEFAULT_VALUE, COMMAND_LINE_VALUE).
""" """
def _help(): def _help():
print_(_usage) print_(_usage)
sys.exit(0) sys.exit(0)
def _version():
version = pkg_resources.working_set.find(
pkg_resources.Requirement.parse('zc.buildout')).version
print_("buildout version %s" % version)
sys.exit(0)
def main(args=None): def main(args=None):
if args is None: if args is None:
args = sys.argv[1:] args = sys.argv[1:]
...@@ -1772,6 +1783,8 @@ def main(args=None): ...@@ -1772,6 +1783,8 @@ def main(args=None):
elif op: elif op:
if orig_op == '--help': if orig_op == '--help':
_help() _help()
elif orig_op == '--version':
_version()
_error("Invalid option", '-'+op[0]) _error("Invalid option", '-'+op[0])
elif '=' in args[0]: elif '=' in args[0]:
option, value = args.pop(0).split('=', 1) option, value = args.pop(0).split('=', 1)
......
...@@ -595,6 +595,15 @@ def test_help(): ...@@ -595,6 +595,15 @@ def test_help():
... ...
""" """
def test_version():
"""
>>> buildout = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print_(system(buildout+' --version'))
... # doctest: +ELLIPSIS
buildout version ...
"""
def test_bootstrap_with_extension(): def test_bootstrap_with_extension():
""" """
We had a problem running a bootstrap with an extension. Let's make We had a problem running a bootstrap with an extension. Let's make
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment