diff options
| author | Cedric Brandily <zzelle@gmail.com> | 2015-03-17 23:44:53 +0100 |
|---|---|---|
| committer | Cedric Brandily <zzelle@gmail.com> | 2015-03-17 23:44:53 +0100 |
| commit | 8e92dfc2a56c47579c77276cd2c4ce43053603b6 (patch) | |
| tree | bfd33c1b347275a3798cd6a20d4eb53bd55a3a1b /openstackclient/shell.py | |
| parent | a8c44074f93815ea670d4bc09156795c66505f31 (diff) | |
| download | python-openstackclient-8e92dfc2a56c47579c77276cd2c4ce43053603b6.tar.gz | |
Use cliff deferred help instead of homemade one
This change removes openstackclient homemade hack to defer help
printing in initialize_app and uses cliff (new) option to defer
help printing.
Change-Id: Ie3e94ec96254745bfef8c5ff5abc405facfe1bea
Related-Bug: #1316622
Diffstat (limited to 'openstackclient/shell.py')
| -rw-r--r-- | openstackclient/shell.py | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py index 3cfd7312..141dcd66 100644 --- a/openstackclient/shell.py +++ b/openstackclient/shell.py @@ -76,7 +76,8 @@ class OpenStackShell(app.App): super(OpenStackShell, self).__init__( description=__doc__.strip(), version=openstackclient.__version__, - command_manager=commandmanager.CommandManager('openstack.cli')) + command_manager=commandmanager.CommandManager('openstack.cli'), + deferred_help=True) self.api_version = {} @@ -92,35 +93,6 @@ class OpenStackShell(app.App): self.client_manager = None - # NOTE(dtroyer): This hack changes the help action that Cliff - # automatically adds to the parser so we can defer - # its execution until after the api-versioned commands - # have been loaded. There doesn't seem to be a - # way to edit/remove anything from an existing parser. - - # Replace the cliff-added help.HelpAction to defer its execution - self.DeferredHelpAction = None - for a in self.parser._actions: - if type(a) == help.HelpAction: - # Found it, save and replace it - self.DeferredHelpAction = a - - # These steps are argparse-implementation-dependent - self.parser._actions.remove(a) - if self.parser._option_string_actions['-h']: - del self.parser._option_string_actions['-h'] - if self.parser._option_string_actions['--help']: - del self.parser._option_string_actions['--help'] - - # Make a new help option to just set a flag - self.parser.add_argument( - '-h', '--help', - action='store_true', - dest='deferred_help', - default=False, - help="Show this help message and exit", - ) - def configure_logging(self): """Configure logging for the app @@ -276,8 +248,7 @@ class OpenStackShell(app.App): # set up additional clients to stuff in to client_manager?? # Handle deferred help and exit - if self.options.deferred_help: - self.DeferredHelpAction(self.parser, self.parser, None, None) + self.print_help_if_requested() # Set up common client session if self.options.os_cacert: |
