1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Output version string when --version is passed using optparse's version argument

This commit is contained in:
willthames 2012-07-30 10:28:11 +10:00
parent f5e08158ca
commit ad9b8e2312

View file

@ -26,6 +26,7 @@ import optparse
import operator import operator
from ansible import errors from ansible import errors
from ansible import color from ansible import color
from ansible import __version__
import ansible.constants as C import ansible.constants as C
try: 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): 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 ''' ''' 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", parser.add_option('-v','--verbose', default=False, action="store_true",
help='verbose mode') help='verbose mode')
parser.add_option('-f','--forks', dest='forks', default=constants.DEFAULT_FORKS, type='int', parser.add_option('-f','--forks', dest='forks', default=constants.DEFAULT_FORKS, type='int',