From b08b475447517b9c34afd3230c7bdf837a61c48f Mon Sep 17 00:00:00 2001 From: kschopmeyer Date: Tue, 25 Apr 2017 14:58:24 -0500 Subject: [PATCH] fixes #630 Add --version (-V) to argparse for wbemcli and mof_compiler --- docs/changes.rst | 3 +++ docs/mof_compiler.help.txt | 1 + mof_compiler | 7 ++++++- wbemcli.py | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/changes.rst b/docs/changes.rst index 28e76a87f..e85754a64 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -97,6 +97,9 @@ Bug fixes * Add more mock tests. ModifyInstance was missing and some others were missing an error test. issue#61 +* add --version option to mof_compiler and pywbem cli tools. Generates the + pywbem version string. See issue # 630 + Build, test, quality ^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/mof_compiler.help.txt b/docs/mof_compiler.help.txt index fe36c314f..0ee4327a4 100644 --- a/docs/mof_compiler.help.txt +++ b/docs/mof_compiler.help.txt @@ -82,6 +82,7 @@ General options: Path name of a MOF include directory. Can be specified multiple times. -v, --verbose Print more messages while processing + -V, --version Display pywbem version and exit. -h, --help Show this help message and exit Example: mof_compiler CIM_Schema_2.45.mof -s https://localhost -n root/cimv2 diff --git a/mof_compiler b/mof_compiler index aba163561..a634bf375 100755 --- a/mof_compiler +++ b/mof_compiler @@ -37,6 +37,7 @@ from pywbem._cliutils import SmartFormatter from pywbem import WBEMConnection, Error from pywbem.mof_compiler import MOFWBEMConnection, MOFCompiler from pywbem.cim_http import get_default_ca_cert_paths +from pywbem import __version__ def main(): @@ -164,6 +165,9 @@ Example: '-v', '--verbose', dest='verbose', action='store_true', default=False, help='Print more messages while processing') + general_arggroup.add_argument( + '-V', '--version', action='version', version='%(prog)s ' + __version__, + help='Display pywbem version and exit.') general_arggroup.add_argument( '-h', '--help', action='help', help='Show this help message and exit') @@ -240,6 +244,7 @@ Example: if args.remove or args.dry_run: # Only record the changes to the repository, but do not perform them. + # pylint: disable=redefined-variable-type conn = MOFWBEMConnection(conn=conn) # conn.debug = True @@ -285,5 +290,5 @@ Example: if __name__ == '__main__': - rc = main() + rc = main() # pylint: disable=invalid-name sys.exit(rc) diff --git a/wbemcli.py b/wbemcli.py index 75d5c84a7..556d98039 100644 --- a/wbemcli.py +++ b/wbemcli.py @@ -58,6 +58,7 @@ from pywbem.cim_http import get_default_ca_cert_paths from pywbem._cliutils import SmartFormatter as _SmartFormatter from pywbem.config import DEFAULT_ITER_MAXOBJECTCOUNT +from pywbem import __version__ # Connection global variable. Set by remote_connection and use # by all functions that execute operations. @@ -2953,6 +2954,9 @@ def _main(): '-v', '--verbose', dest='verbose', action='store_true', default=False, help='Print more messages while processing') + general_arggroup.add_argument( + '-V', '--version', action='version', version='%(prog)s ' + __version__, + help='Display pywbem version and exit.') general_arggroup.add_argument( '-e', '--enable_stats', dest='verbose', action='store_true', default=False,