mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
add git commit hash to --version output
This commit is contained in:
@@ -38,8 +38,7 @@ class CommandlineParser:
|
||||
dest='subcommand')
|
||||
|
||||
# Global arguments that only work if no sub-command given
|
||||
self.parser.add_argument('--version', action='version',
|
||||
version=CommandlineParser.nominatim_version_text(),
|
||||
self.parser.add_argument('--version', action='store_true',
|
||||
help='Print Nominatim version and exit')
|
||||
|
||||
# Arguments added to every sub-command
|
||||
@@ -61,7 +60,10 @@ class CommandlineParser:
|
||||
def nominatim_version_text():
|
||||
""" Program name and version number as string
|
||||
"""
|
||||
return "Nominatim version %s.%s.%s.%s\n" % version.NOMINATIM_VERSION
|
||||
text = 'Nominatim version %s.%s.%s.%s' % version.NOMINATIM_VERSION
|
||||
if version.GIT_COMMIT_HASH is not None:
|
||||
text += ' (%s)' % version.GIT_COMMIT_HASH
|
||||
return text
|
||||
|
||||
def add_subcommand(self, name, cmd):
|
||||
""" Add a subcommand to the parser. The subcommand must be a class
|
||||
@@ -86,6 +88,10 @@ class CommandlineParser:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user