-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathinstall.py
More file actions
117 lines (96 loc) · 3.54 KB
/
Copy pathinstall.py
File metadata and controls
117 lines (96 loc) · 3.54 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env python3
"""Installer / Uninstaller for Token-Saver extension.
Cross-platform: macOS, Linux, Windows.
Usage:
python3 install.py --target claude # Install for Claude Code
python3 install.py --target antigravity # Install for Antigravity CLI
python3 install.py --target both # Install for both
python3 install.py --link # Use symlinks (development mode)
python3 install.py --uninstall # Remove from both platforms
python3 install.py --uninstall --target claude # Remove from Claude Code only
"""
import argparse
import platform
from installers import antigravity, claude
from installers.common import (
install_cli,
install_core,
migrate_from_legacy,
uninstall_cli,
uninstall_core,
uninstall_data_dir,
)
def main():
parser = argparse.ArgumentParser(
description="Install or uninstall Token-Saver extension",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python3 install.py --target claude Install for Claude Code
python3 install.py --target antigravity Install for Antigravity CLI
python3 install.py --target both Install for both
python3 install.py --link --target claude Dev mode (symlinks)
python3 install.py --uninstall Uninstall from both (default)
python3 install.py --uninstall --target claude Uninstall from Claude only
python3 install.py --uninstall --keep-data Uninstall but keep stats DB
""",
)
parser.add_argument(
"--target",
choices=["claude", "antigravity", "both"],
default=None,
help="Target platform (default: claude for install, both for uninstall)",
)
parser.add_argument(
"--link",
action="store_true",
help="Use symlinks instead of copies (development mode)",
)
parser.add_argument(
"--uninstall",
action="store_true",
help="Remove the extension completely",
)
parser.add_argument(
"--keep-data",
action="store_true",
help="When uninstalling, keep the ~/.token-saver data directory (stats, config)",
)
args = parser.parse_args()
if args.uninstall:
# Default to 'both' for uninstall so nothing is left behind
target = args.target or "both"
print(f"Uninstalling token-saver from: {target}")
print("\n--- Legacy cleanup ---")
migrate_from_legacy()
print("\n--- CLI ---")
uninstall_cli()
if target in ("claude", "both"):
claude.uninstall()
if target in ("antigravity", "both"):
antigravity.uninstall()
print("\n--- Core ---")
uninstall_core()
if not args.keep_data:
print("\n--- Data ---")
uninstall_data_dir()
print("\nUninstallation complete.")
return
# --- Install ---
target = args.target or "claude"
print(f"Installing token-saver for: {target}")
print(f"Platform: {platform.system()}")
print(f"Mode: {'symlink' if args.link else 'copy'}")
# Clean up any leftover "token-saving" installation before proceeding
print("\n--- Legacy cleanup ---")
migrate_from_legacy()
if target in ("claude", "both"):
claude.install(use_symlink=args.link)
if target in ("antigravity", "both"):
antigravity.install(use_symlink=args.link)
install_core(use_symlink=args.link)
print("\n--- CLI ---")
install_cli(use_symlink=args.link)
print("\nInstallation complete.")
if __name__ == "__main__":
main()