diff options
| author | gongysh <gongysh@cn.ibm.com> | 2012-12-11 23:40:16 +0800 |
|---|---|---|
| committer | Akihiro MOTOKI <motoki@da.jp.nec.com> | 2013-01-13 23:09:08 +0900 |
| commit | ee3ab2d7afb57abf574a31bbb72e4c94dde099df (patch) | |
| tree | 374bde7f74fb08848d07febf940b41201e528711 /quantumclient/shell.py | |
| parent | 093bac1bc6749326857241ca226a4219917891e7 (diff) | |
| download | python-neutronclient-ee3ab2d7afb57abf574a31bbb72e4c94dde099df.tar.gz | |
Allow known options defined after position arguments.
We run the argument parser to split known options and unknown options.
Make '-' work and have the same effect as '_' in both known and unknown
option parts.
Make metavar Uppercase.
blueprint options-location
Change-Id: Ic27b278484133c8b83e3b031a0810a76b050219f
Diffstat (limited to 'quantumclient/shell.py')
| -rw-r--r-- | quantumclient/shell.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/quantumclient/shell.py b/quantumclient/shell.py index 038ce20..da36bd0 100644 --- a/quantumclient/shell.py +++ b/quantumclient/shell.py @@ -365,6 +365,46 @@ class QuantumShell(App): result = self.run_subcommand(remainder) return result + def run_subcommand(self, argv): + subcommand = self.command_manager.find_command(argv) + cmd_factory, cmd_name, sub_argv = subcommand + cmd = cmd_factory(self, self.options) + err = None + result = 1 + try: + self.prepare_to_run_command(cmd) + full_name = (cmd_name + if self.interactive_mode + else ' '.join([self.NAME, cmd_name]) + ) + cmd_parser = cmd.get_parser(full_name) + known_args, values_specs = cmd_parser.parse_known_args(sub_argv) + cmd.values_specs = values_specs + result = cmd.run(known_args) + except Exception as err: + if self.options.debug: + self.log.exception(err) + else: + self.log.error(err) + try: + self.clean_up(cmd, result, err) + except Exception as err2: + if self.options.debug: + self.log.exception(err2) + else: + self.log.error('Could not clean up: %s', err2) + if self.options.debug: + raise + else: + try: + self.clean_up(cmd, result, None) + except Exception as err3: + if self.options.debug: + self.log.exception(err3) + else: + self.log.error('Could not clean up: %s', err3) + return result + def authenticate_user(self): """Make sure the user has provided all of the authentication info we need. |
