import argparse import sys from scripts import ( add_worktree, remove_worktree, add_commit, new_branch, ) def help_menu(): parser = argparse.ArgumentParser( add_help=False, description="Git Formatter", prog="gft", formatter_class=argparse.RawTextHelpFormatter ) worktree_group = parser.add_argument_group('Worktree Options') branch_group = parser.add_argument_group('Branch Options') commit_group = parser.add_argument_group('Commit Options') options_group = parser.add_argument_group('General Options') worktree_group.add_argument( '-a', default=False, metavar="worktree", nargs='?', help="Create a git worktree", ) worktree_group.add_argument( '-i', default=False, metavar="worktree", nargs='?', help="Create a git worktree and automatically install npm packages", ) worktree_group.add_argument( '-r', default=False, metavar="worktree", nargs='?', help="Remove a git worktree", ) branch_group.add_argument( '-b', default=False, metavar="branch", nargs='?', help="Create a branch", ) commit_group.add_argument( '-m', default=False, metavar="message", nargs='?', help="Commit changes with a formatted message", ) options_group.add_argument( '-h', '--help', action='help', help='Show this help menu' ) if len(sys.argv) == 1: parser.print_help() exit(0) return parser.parse_args() def main(): args = help_menu() if args.a is not False: add_worktree(args.a) if args.i is not False: add_worktree(args.i, True) if args.r is not False: remove_worktree(args.r) if args.b is not False: new_branch() if args.m is not False: add_commit(args.m) if __name__ == '__main__': main()