@@ -77,8 +77,8 @@ def cls_to_what(cls):
7777return 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 ,
8282description = "GitLab API Command Line Interface" )
8383parser .add_argument ("--version" ,help = "Display the version." ,
8484action = "store_true" )
@@ -132,14 +132,20 @@ def main():
132132print (gitlab .__version__ )
133133exit (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
138141config = gitlab .config .GitlabConfigParser (options .gitlab ,
139142options .config_file )
140143cli_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
141146parser = _get_parser (cli_module )
142147args = parser .parse_args (sys .argv [1 :])
148+
143149config_files = args .config_file
144150gitlab_id = args .gitlab
145151verbose = args .verbose