summaryrefslogtreecommitdiff
path: root/quantumclient/shell.py
diff options
context:
space:
mode:
authorYong Sheng Gong <gongysh@cn.ibm.com>2012-08-12 11:16:47 +0800
committerYong Sheng Gong <gongysh@cn.ibm.com>2012-08-12 11:18:01 +0800
commit80e89c929bb5aeddc8a31288ad5f7b749e24e4f5 (patch)
treeb62493b0e98cd1d99c334dbeda0275e2752b21d1 /quantumclient/shell.py
parentdefb5481b0e7e2469405de98e6dd49ed239ef986 (diff)
downloadpython-neutronclient-80e89c929bb5aeddc8a31288ad5f7b749e24e4f5.tar.gz
enable -h | --help after command to show the command usage.
Bug #1023260 we caculate the position of -h|--help and command, if -h|--help is after command, we replace the command with 'help' command. Change-Id: Ieb5fc9d37daafd704edb71e35b74dbf83cb69a4c
Diffstat (limited to 'quantumclient/shell.py')
-rw-r--r--quantumclient/shell.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/quantumclient/shell.py b/quantumclient/shell.py
index a409758..b751545 100644
--- a/quantumclient/shell.py
+++ b/quantumclient/shell.py
@@ -219,6 +219,19 @@ class QuantumShell(App):
:paramtype argv: list of str
"""
try:
+ index = 0
+ command_pos = -1
+ help_pos = -1
+ for arg in argv:
+ if arg in COMMANDS[self.api_version]:
+ if command_pos == -1:
+ command_pos = index
+ elif arg in ('-h', '--help'):
+ if help_pos == -1:
+ help_pos = index
+ index = index + 1
+ if command_pos > -1 and help_pos > command_pos:
+ argv = ['help', argv[command_pos]]
self.options, remainder = self.parser.parse_known_args(argv)
self.configure_logging()
self.interactive_mode = not remainder