Commit 0980e375 authored by Jim Fulton's avatar Jim Fulton

Merge pull request #62 from mgedmin/buildout--version

Add bin/buildout --version
parents 8c13789c 72cceb15
...@@ -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