from nominatim.tools.exec_utils import run_legacy_script, run_php_server
from nominatim.errors import UsageError
from nominatim import clicmd
+from nominatim import version
from nominatim.clicmd.args import NominatimArgs
LOG = logging.getLogger()
self.subs = self.parser.add_subparsers(title='available commands',
dest='subcommand')
+ # Global arguments that only work if no sub-command given
+ self.parser.add_argument('--version', action='store_true',
+ help='Print Nominatim version and exit')
+
# Arguments added to every sub-command
self.default_args = argparse.ArgumentParser(add_help=False)
group = self.default_args.add_argument_group('Default arguments')
group.add_argument('-j', '--threads', metavar='NUM', type=int,
help='Number of parallel threads to use')
+ @staticmethod
+ def nominatim_version_text():
+ """ Program name and version number as string
+ """
+ text = f'Nominatim version {version.version_str()}'
+ if version.GIT_COMMIT_HASH is not None:
+ text += f' ({version.GIT_COMMIT_HASH})'
+ return text
def add_subcommand(self, name, cmd):
""" Add a subcommand to the parser. The subcommand must be a class
except SystemExit:
return 1
+ if args.version:
+ print(CommandlineParser.nominatim_version_text())
+ return 0
+
if args.subcommand is None:
self.parser.print_help()
return 1