options: add --version option and handle empty argument list
Added the -V/--version option to print the rteval version number
and exit.
Added code to handle no arguments, which will trigger a usage message
from the option parser.
Signed-off-by: Clark Williams <williams@redhat.com>
diff --git a/rteval-cmd b/rteval-cmd
index 37be072..2b4b80b 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -41,7 +41,7 @@
from rteval import RtEval, rtevalConfig
from rteval.modules.loads import LoadModules
from rteval.modules.measurement import MeasurementModules
-
+from rteval.version import RTEVAL_VERSION
def summarize(repfile, xslt):
@@ -153,8 +153,18 @@
parser.add_option("-O", "--onlyload", dest="rteval___onlyload",
action='store_true', default=False,
help="only run the loads (don't run measurement threads)")
+ parser.add_option("-V", "--version", dest="rteval__version",
+ action='store_true', default=False,
+ help='print rteval version and exit')
+
+ if not cmdargs:
+ cmdargs = ["--help"]
(cmd_opts, cmd_args) = parser.parse_args(args = cmdargs)
+ if cmd_opts.rteval__version:
+ print("rteval version %s" % RTEVAL_VERSION)
+ sys.exit(0);
+
if cmd_opts.rteval___duration:
mult = 1.0
v = cmd_opts.rteval___duration.lower()