File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,8 @@ def cls_to_what(cls):
7777 return camel_re .sub (r'\1-\2' , cls .__name__ ).lower ()
7878
7979
80- def _get_base_parser ():
81- parser = argparse .ArgumentParser (
80+ def _get_base_parser (add_help = True ):
81+ parser = argparse .ArgumentParser (add_help = add_help ,
8282 description = "GitLab API Command Line Interface" )
8383 parser .add_argument ("--version" , help = "Display the version." ,
8484 action = "store_true" )
@@ -132,14 +132,20 @@ def main():
132132 print (gitlab .__version__ )
133133 exit (0 )
134134
135- parser = _get_base_parser ()
135+ parser = _get_base_parser (add_help = False )
136+ # This first parsing step is used to find the gitlab config to use, and
137+ # load the propermodule (v3 or v4) accordingly. At that point we don't have
138+ # any subparser setup
136139 (options , args ) = parser .parse_known_args (sys .argv )
137140
138141 config = gitlab .config .GitlabConfigParser (options .gitlab ,
139142 options .config_file )
140143 cli_module = importlib .import_module ('gitlab.v%s.cli' % config .api_version )
144+
145+ # Now we build the entire set of subcommands and do the complete parsing
141146 parser = _get_parser (cli_module )
142147 args = parser .parse_args (sys .argv [1 :])
148+
143149 config_files = args .config_file
144150 gitlab_id = args .gitlab
145151 verbose = args .verbose
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ def extend_parser(parser):
240240 arg_name = cli .cls_to_what (cls )
241241 object_group = subparsers .add_parser (arg_name )
242242
243- object_subparsers = object_group .add_subparsers (
243+ object_subparsers = object_group .add_subparsers (title = 'action' ,
244244 dest = 'action' , help = "Action to execute." )
245245 _populate_sub_parser_by_class (cls , object_subparsers )
246246 object_subparsers .required = True
You can’t perform that action at this time.
0 commit comments