Make "gptbot -v" actually output the correct version

This commit is contained in:
Kumi 2023-12-07 19:43:30 +01:00
parent 04662fc1f3
commit 2b7813f715
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -5,11 +5,18 @@ from configparser import ConfigParser
import signal
import asyncio
import pkg_resources
def sigterm_handler(_signo, _stack_frame):
exit()
def get_version():
try:
package_version = pkg_resources.get_distribution("matrix_gptbot").version
except pkg_resources.DistributionNotFound:
return None
return package_version
if __name__ == "__main__":
# Parse command line arguments
@ -25,7 +32,7 @@ if __name__ == "__main__":
"-v",
help="Print version and exit",
action="version",
version="GPTBot v0.1.1",
version=f"GPTBot {get_version() or '- version unknown'}",
)
args = parser.parse_args()