Make "gptbot -v" actually output the correct version
This commit is contained in:
parent
04662fc1f3
commit
2b7813f715
1 changed files with 9 additions and 2 deletions
|
@ -5,11 +5,18 @@ from configparser import ConfigParser
|
||||||
|
|
||||||
import signal
|
import signal
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
def sigterm_handler(_signo, _stack_frame):
|
def sigterm_handler(_signo, _stack_frame):
|
||||||
exit()
|
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__":
|
if __name__ == "__main__":
|
||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
|
@ -25,7 +32,7 @@ if __name__ == "__main__":
|
||||||
"-v",
|
"-v",
|
||||||
help="Print version and exit",
|
help="Print version and exit",
|
||||||
action="version",
|
action="version",
|
||||||
version="GPTBot v0.1.1",
|
version=f"GPTBot {get_version() or '- version unknown'}",
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue