feat: Add version flag (-v) to print program version

This commit is contained in:
n loewen (aider) 2025-06-07 18:57:36 +01:00
parent b14bde6d7e
commit 02a40fd234
1 changed files with 10 additions and 3 deletions

13
gtm
View File

@ -4,6 +4,8 @@ import curses
import subprocess import subprocess
import sys import sys
VERSION = "2025-06-07"
def get_commits(filename): def get_commits(filename):
cmd = ['git', 'log', '--pretty=format:%h %ad %s', '--date=short', '--', filename] cmd = ['git', 'log', '--pretty=format:%h %ad %s', '--date=short', '--', filename]
result = subprocess.run(cmd, capture_output=True, text=True) result = subprocess.run(cmd, capture_output=True, text=True)
@ -219,9 +221,14 @@ def main(stdscr, filename):
stdscr.refresh() stdscr.refresh()
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) != 2: if len(sys.argv) == 2:
print("Usage: gtm filename") if sys.argv[1] == "-v":
sys.exit(1) print(f"gtm version {VERSION}")
sys.exit(0)
filename = sys.argv[1] filename = sys.argv[1]
curses.wrapper(main, filename) curses.wrapper(main, filename)
else:
print("Usage: gtm filename")
print(" gtm -v (show version)")
sys.exit(1)