feat: Add version flag (-v) to print program version
This commit is contained in:
parent
b14bde6d7e
commit
02a40fd234
13
gtm
13
gtm
|
|
@ -4,6 +4,8 @@ import curses
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
VERSION = "2025-06-07"
|
||||
|
||||
def get_commits(filename):
|
||||
cmd = ['git', 'log', '--pretty=format:%h %ad %s', '--date=short', '--', filename]
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
|
|
@ -219,9 +221,14 @@ def main(stdscr, filename):
|
|||
stdscr.refresh()
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
if len(sys.argv) == 2:
|
||||
if sys.argv[1] == "-v":
|
||||
print(f"gtm version {VERSION}")
|
||||
sys.exit(0)
|
||||
filename = sys.argv[1]
|
||||
curses.wrapper(main, filename)
|
||||
else:
|
||||
print("Usage: gtm filename")
|
||||
print(" gtm -v (show version)")
|
||||
sys.exit(1)
|
||||
filename = sys.argv[1]
|
||||
curses.wrapper(main, filename)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue