-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitpatch.py
More file actions
36 lines (28 loc) · 1.45 KB
/
Copy pathgitpatch.py
File metadata and controls
36 lines (28 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import argparse
from patch_manager import save_patch, list_patches, apply_patch
def main():
parser = argparse.ArgumentParser(description="GitPatch CLI Tool")
subparsers = parser.add_subparsers(dest="command", required=True)
# save
save_parser = subparsers.add_parser("save", help="Save a patch file")
save_parser.add_argument("patch_file", help="Path to patch file")
save_parser.add_argument("--name", "-n", required=True, help="Patch name")
save_parser.add_argument("--tag", "-t", required=True, help="Patch tag")
save_parser.add_argument("--storage", "-s", default=".", help="Storage directory")
# list
list_parser = subparsers.add_parser("list", help="List saved patches")
list_parser.add_argument("--storage", "-s", default=".", help="Storage directory")
# apply
apply_parser = subparsers.add_parser("apply", help="Apply the latest matching patch")
apply_parser.add_argument("--name", "-n", required=True, help="Patch name")
apply_parser.add_argument("--tag", "-t", required=True, help="Patch tag")
apply_parser.add_argument("--storage", "-s", default=".", help="Storage directory")
args = parser.parse_args()
if args.command == "save":
save_patch(args.patch_file, args.name, args.tag, args.storage)
elif args.command == "list":
list_patches(args.storage)
elif args.command == "apply":
apply_patch(args.name, args.tag, args.storage)
if __name__ == "__main__":
main()