]> git.openstreetmap.org Git - nominatim.git/commitdiff
optionally hand in command line arguments to CLI functions
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 20 Jan 2021 08:04:04 +0000 (09:04 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 20 Jan 2021 20:30:27 +0000 (21:30 +0100)
Allows easier testing.

nominatim/cli.py

index 70481b4a6fd86cbc290a676a992ae4fe40122cef..02b30f19e438e516ceb15a8e34ea197d1c49380d 100644 (file)
@@ -68,10 +68,11 @@ class CommandlineParser:
         """ Parse the command line arguments of the program and execute the
             appropriate subcommand.
         """
-        args = self.parser.parse_args()
+        args = self.parser.parse_args(args=kwargs.get('cli_args'))
 
         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'):
             setattr(args, arg, Path(kwargs[arg]))