diff options
| author | Yong Sheng Gong <gongysh@cn.ibm.com> | 2012-08-12 11:16:47 +0800 |
|---|---|---|
| committer | Yong Sheng Gong <gongysh@cn.ibm.com> | 2012-08-12 11:18:01 +0800 |
| commit | 80e89c929bb5aeddc8a31288ad5f7b749e24e4f5 (patch) | |
| tree | b62493b0e98cd1d99c334dbeda0275e2752b21d1 /quantumclient/shell.py | |
| parent | defb5481b0e7e2469405de98e6dd49ed239ef986 (diff) | |
| download | python-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.py | 13 |
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 |
