optionally hand in command line arguments to CLI functions

Allows easier testing.
This commit is contained in:
Sarah Hoffmann
2021-01-20 09:04:04 +01:00
parent bfa6580ad5
commit 041ae67fd9

View File

@@ -68,10 +68,11 @@ class CommandlineParser:
""" Parse the command line arguments of the program and execute the """ Parse the command line arguments of the program and execute the
appropriate subcommand. appropriate subcommand.
""" """
args = self.parser.parse_args() args = self.parser.parse_args(args=kwargs.get('cli_args'))
if args.subcommand is None: if args.subcommand is None:
return self.parser.print_help() self.parser.print_help()
return 1
for arg in ('module_dir', 'osm2pgsql_path', 'phplib_dir', 'data_dir', 'phpcgi_path'): for arg in ('module_dir', 'osm2pgsql_path', 'phplib_dir', 'data_dir', 'phpcgi_path'):
setattr(args, arg, Path(kwargs[arg])) setattr(args, arg, Path(kwargs[arg]))