@@ -76,7 +76,8 @@ def __init__(self):
7676 super (OpenStackShell , self ).__init__ (
7777 description = __doc__ .strip (),
7878 version = openstackclient .__version__ ,
79- command_manager = commandmanager .CommandManager ('openstack.cli' ))
79+ command_manager = commandmanager .CommandManager ('openstack.cli' ),
80+ deferred_help = True )
8081
8182 self .api_version = {}
8283
@@ -92,35 +93,6 @@ def __init__(self):
9293
9394 self .client_manager = None
9495
95- # NOTE(dtroyer): This hack changes the help action that Cliff
96- # automatically adds to the parser so we can defer
97- # its execution until after the api-versioned commands
98- # have been loaded. There doesn't seem to be a
99- # way to edit/remove anything from an existing parser.
100-
101- # Replace the cliff-added help.HelpAction to defer its execution
102- self .DeferredHelpAction = None
103- for a in self .parser ._actions :
104- if type (a ) == help .HelpAction :
105- # Found it, save and replace it
106- self .DeferredHelpAction = a
107-
108- # These steps are argparse-implementation-dependent
109- self .parser ._actions .remove (a )
110- if self .parser ._option_string_actions ['-h' ]:
111- del self .parser ._option_string_actions ['-h' ]
112- if self .parser ._option_string_actions ['--help' ]:
113- del self .parser ._option_string_actions ['--help' ]
114-
115- # Make a new help option to just set a flag
116- self .parser .add_argument (
117- '-h' , '--help' ,
118- action = 'store_true' ,
119- dest = 'deferred_help' ,
120- default = False ,
121- help = "Show this help message and exit" ,
122- )
123-
12496 def configure_logging (self ):
12597 """Configure logging for the app
12698
@@ -281,8 +253,7 @@ def initialize_app(self, argv):
281253 # set up additional clients to stuff in to client_manager??
282254
283255 # Handle deferred help and exit
284- if self .options .deferred_help :
285- self .DeferredHelpAction (self .parser , self .parser , None , None )
256+ self .print_help_if_requested ()
286257
287258 # Set up common client session
288259 if self .options .os_cacert :
0 commit comments