From ad9b8e23128dcbf30a4353603b35e8e5e66a7ca9 Mon Sep 17 00:00:00 2001 From: willthames Date: Mon, 30 Jul 2012 10:28:11 +1000 Subject: [PATCH] Output version string when --version is passed using optparse's version argument --- lib/ansible/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/utils.py b/lib/ansible/utils.py index c8bab97397..4d4d7fa96a 100644 --- a/lib/ansible/utils.py +++ b/lib/ansible/utils.py @@ -26,6 +26,7 @@ import optparse import operator from ansible import errors from ansible import color +from ansible import __version__ import ansible.constants as C try: @@ -279,7 +280,7 @@ class SortedOptParser(optparse.OptionParser): def base_parser(constants=C, usage="", output_opts=False, runas_opts=False, async_opts=False, connect_opts=False): ''' create an options parser for any ansible script ''' - parser = SortedOptParser(usage) + parser = SortedOptParser(usage, version="%prog " + __version__) parser.add_option('-v','--verbose', default=False, action="store_true", help='verbose mode') parser.add_option('-f','--forks', dest='forks', default=constants.DEFAULT_FORKS, type='int',