refactor: Update command-line options to use no-* flags for diff, mouse, numbers, and wrap
This commit is contained in:
parent
cde7065c08
commit
31d6e0ef55
27
gtm
27
gtm
|
|
@ -1501,7 +1501,7 @@ def handle_keyboard_input(key, state: AppState) -> AppState:
|
|||
|
||||
# --- Main Application ---
|
||||
|
||||
def main(stdscr, filename, show_add, show_del, mouse=True, show_diff=True, wrap_lines=True, show_line_numbers=True):
|
||||
def main(stdscr, filename, show_add, show_del, mouse=True, no_diff=False, wrap_lines=True, show_line_numbers=True):
|
||||
try:
|
||||
curses.curs_set(0)
|
||||
except:
|
||||
|
|
@ -1519,8 +1519,8 @@ def main(stdscr, filename, show_add, show_del, mouse=True, show_diff=True, wrap_
|
|||
curses.init_pair(7, 7, -1) # Regular line numbers
|
||||
|
||||
height, width = stdscr.getmaxyx()
|
||||
# If show_diff is true, enable both additions and deletions
|
||||
if show_diff:
|
||||
# If no_diff is false, enable both additions and deletions
|
||||
if not show_diff:
|
||||
show_add = True
|
||||
show_del = True
|
||||
|
||||
|
|
@ -1586,13 +1586,10 @@ def main(stdscr, filename, show_add, show_del, mouse=True, show_diff=True, wrap_
|
|||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="A \"Git Time Machine\" for viewing file history")
|
||||
parser.add_argument("-d", "--diff", action="store_true", help="Highlight newly added and deleted lines")
|
||||
parser.add_argument("--diff-additions", action="store_true", help="Highlight newly added lines in green")
|
||||
parser.add_argument("--diff-deletions", action="store_true", help="Show deleted lines in red")
|
||||
parser.add_argument("--no-diff", action="store_true", help="Don't highlight added and deleted lines")
|
||||
parser.add_argument("--no-mouse", action="store_true", help="Disable mouse support")
|
||||
parser.add_argument("--mouse", action="store_true", help="Enable mouse support (default)")
|
||||
parser.add_argument("--no-wrap", action="store_true", help="Disable line wrapping")
|
||||
parser.add_argument("--line-numbers", action="store_true", help="Show line numbers")
|
||||
parser.add_argument("--no-numbers", action="store_true", help="Hide line numbers")
|
||||
parser.add_argument("-v", "--version", action="store_true", help="Show version number")
|
||||
parser.add_argument("filename", nargs="?", help="File to view history for")
|
||||
|
||||
|
|
@ -1620,5 +1617,15 @@ if __name__ == "__main__":
|
|||
sys.exit(1)
|
||||
|
||||
# Always enable mouse by default, only disable if --no-mouse is explicitly set
|
||||
mouse_enabled = True if not args.no_mouse else False
|
||||
curses.wrapper(main, filename, args.diff, args.diff_additions, args.diff_deletions, mouse_enabled, not args.no_wrap, args.line_numbers)
|
||||
mouse_enabled = not args.no_mouse
|
||||
|
||||
# Set diff mode (enabled by default)
|
||||
show_diff = not args.no_diff
|
||||
|
||||
# Set line numbers (enabled by default)
|
||||
show_line_numbers = not args.no_numbers
|
||||
|
||||
# Set line wrapping (enabled by default)
|
||||
wrap_lines = not args.no_wrap
|
||||
|
||||
curses.wrapper(main, filename, show_diff, show_diff, mouse_enabled, args.no_diff, wrap_lines, show_line_numbers)
|
||||
|
|
|
|||
|
|
@ -9,13 +9,10 @@ Basic usage: `gtm [filename]`
|
|||
|
||||
```
|
||||
-h, --help show this help message and exit
|
||||
-d, --diff Highlight newly added and deleted lines
|
||||
--diff-additions Highlight newly added lines in green
|
||||
--diff-deletions Show deleted lines in red
|
||||
--no-diff Don't highlight added and deleted lines
|
||||
--no-mouse Disable mouse support
|
||||
--mouse Enable mouse support (default)
|
||||
--no-wrap Disable line wrapping
|
||||
--line-numbers Show line numbers
|
||||
--no-numbers Hide line numbers
|
||||
-v, --version Show version number
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue