Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
---------------------------------------------------------------
commit 21d86fe144b997c3fa6911ee91ab2ddcc3e3870d
Author: Peter Hatina <phatina(a)redhat.com>
Date: Tue Jan 15 15:48:36 2013 +0100
add lmishell command line options check
---------------------------------------------------------------
cli-tools/lmishell | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/cli-tools/lmishell b/cli-tools/lmishell
index 82fb4f0..289b459 100755
--- a/cli-tools/lmishell
+++ b/cli-tools/lmishell
@@ -52,6 +52,7 @@ class _LmiShellOptions(object):
self._argv = argv
self._script_name = ""
self._script_argv = []
+ self._good = True
self._inspect = False
self._help = False
for a in self._argv[1:]:
@@ -62,8 +63,15 @@ class _LmiShellOptions(object):
self._inspect = True
elif not self._script_name and not a.startswith("-"):
self._script_name = a
- else:
+ elif self._script_name:
self._script_argv.append(a)
+ else:
+ self._good = False
+ break
+
+ @property
+ def good(self):
+ return self._good
@property
def help(self):
@@ -257,6 +265,11 @@ def _use_display_sugar(use = True):
if __name__ == "__main__":
options = _LmiShellOptions(sys.argv)
+ if not options.good:
+ sys.stderr.write("Wrong tool usage!\n\n")
+ options.print_usage()
+ sys.exit(1)
+
if options.help:
options.print_usage()
sys.exit(0)