File tree 2 files changed +10
-4
lines changed
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):
77
77
return camel_re .sub (r'\1-\2' , cls .__name__ ).lower ()
78
78
79
79
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 ,
82
82
description = "GitLab API Command Line Interface" )
83
83
parser .add_argument ("--version" , help = "Display the version." ,
84
84
action = "store_true" )
@@ -132,14 +132,20 @@ def main():
132
132
print (gitlab .__version__ )
133
133
exit (0 )
134
134
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
136
139
(options , args ) = parser .parse_known_args (sys .argv )
137
140
138
141
config = gitlab .config .GitlabConfigParser (options .gitlab ,
139
142
options .config_file )
140
143
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
141
146
parser = _get_parser (cli_module )
142
147
args = parser .parse_args (sys .argv [1 :])
148
+
143
149
config_files = args .config_file
144
150
gitlab_id = args .gitlab
145
151
verbose = args .verbose
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ def extend_parser(parser):
240
240
arg_name = cli .cls_to_what (cls )
241
241
object_group = subparsers .add_parser (arg_name )
242
242
243
- object_subparsers = object_group .add_subparsers (
243
+ object_subparsers = object_group .add_subparsers (title = 'action' ,
244
244
dest = 'action' , help = "Action to execute." )
245
245
_populate_sub_parser_by_class (cls , object_subparsers )
246
246
object_subparsers .required = True
You can’t perform that action at this time.
0 commit comments