feat: Add -h/--help option to display usage information
This commit is contained in:
parent
4102f6c6f2
commit
6bc4b56ba3
13
gtm
13
gtm
|
|
@ -220,15 +220,24 @@ def main(stdscr, filename):
|
|||
|
||||
stdscr.refresh()
|
||||
|
||||
def show_help():
|
||||
"""Display help information"""
|
||||
print("Usage: gtm filename")
|
||||
print(" gtm -v, --version (show version)")
|
||||
print(" gtm -h, --help (show this help)")
|
||||
print("\nA Git Time Machine for viewing file history.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) == 2:
|
||||
if sys.argv[1] == "-v" or sys.argv[1] == "--version":
|
||||
print(f"gtm version {VERSION}")
|
||||
sys.exit(0)
|
||||
elif sys.argv[1] == "-h" or sys.argv[1] == "--help":
|
||||
show_help()
|
||||
sys.exit(0)
|
||||
filename = sys.argv[1]
|
||||
curses.wrapper(main, filename)
|
||||
else:
|
||||
print("Usage: gtm filename")
|
||||
print(" gtm -v, gtm --version (show version)")
|
||||
show_help()
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue