@@ -232,12 +232,14 @@ def main():
232
232
parser = argparse .ArgumentParser (
233
233
description = "GitLab API Command Line Interface" )
234
234
parser .add_argument ("-v" , "--verbose" , "--fancy" ,
235
- help = "increase output verbosity " ,
235
+ help = "Verbose mode " ,
236
236
action = "store_true" )
237
+ parser .add_argument ("-c" , "--config-file" , action = 'append' ,
238
+ help = ("Configuration file to use. Can be used "
239
+ "multiple times." ))
237
240
parser .add_argument ("--gitlab" ,
238
- help = ("Specifies which python-gitlab.cfg "
239
- "configuration section should be used. "
240
- "If not defined, the default selection "
241
+ help = ("Which configuration section should "
242
+ "be used. If not defined, the default selection "
241
243
"will be used." ),
242
244
required = False )
243
245
@@ -263,10 +265,17 @@ def main():
263
265
arg = parser .parse_args ()
264
266
args = arg .__dict__
265
267
268
+ files = arg .config_file or ['/etc/python-gitlab.cfg' ,
269
+ os .path .expanduser ('~/.python-gitlab.cfg' )]
266
270
# read the config
267
271
config = configparser .ConfigParser ()
268
- config .read (['/etc/python-gitlab.cfg' ,
269
- os .path .expanduser ('~/.python-gitlab.cfg' )])
272
+ try :
273
+ config .read (files )
274
+ except Exception as e :
275
+ print ("Impossible to parse the configuration file(s): %s" %
276
+ str (e ))
277
+ sys .exit (1 )
278
+
270
279
gitlab_id = arg .gitlab
271
280
# conflicts with "gitlab" attribute from GitlabObject class
272
281
args .pop ("gitlab" )
0 commit comments