-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.py
More file actions
executable file
·108 lines (93 loc) · 3.66 KB
/
configure.py
File metadata and controls
executable file
·108 lines (93 loc) · 3.66 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
#!/usr/bin/env python3
"""
Quick setup script for Simply Plural CLI
This script helps you get started with the Simply Plural CLI by:
1. Checking dependencies
2. Testing basic functionality
3. Running the configuration wizard
"""
import sys
import subprocess
from pathlib import Path
def run_command(cmd, description):
"""Run a command and report results"""
print(f"-> {description}...")
try:
result = subprocess.run(cmd, capture_output=True, text=True, shell=True)
if result.returncode == 0:
print(f" [OK] Success")
return True
else:
print(f" [FAIL] Failed: {result.stderr.strip()}")
return False
except Exception as e:
print(f" [FAIL] Error: {e}")
return False
def main():
print("Simply Plural CLI Setup")
print("=" * 50)
# Check if we're in the right directory
sp_file = Path("sp.py")
if not sp_file.exists():
print("Error: sp.py not found in current directory")
print("Please run this from the simplyplural-cli directory")
return 1
# 1. Check Python version
print(f"\n1. Python version: {sys.version.split()[0]}")
if sys.version_info < (3, 7):
print(" [FAIL] Python 3.7+ required")
return 1
else:
print(" [OK] Python version OK")
# 2. Install dependencies
print("\n2. Installing dependencies...")
if run_command("python -m pip install -r requirements.txt", "Installing dependencies from requirements.txt"):
print(" [OK] Dependencies installed")
else:
print(" [WARN] Failed to install dependencies. Try manually:")
print(" python -m pip install -r requirements.txt")
return 1
# 3. Test basic functionality
print("\n3. Testing CLI...")
if run_command("python sp.py --help", "Testing CLI help"):
print(" [OK] CLI is working")
else:
print(" [FAIL] CLI test failed")
return 1
# 4. Run configuration
print("\n4. Configuration setup")
print("The CLI will now guide you through setting up your API token.")
print("You'll need to:")
print(" 1. Open Simply Plural app")
print(" 2. Go to Settings -> Privacy & Security -> API Tokens")
print(" 3. Create a token with permissions: Read members, Read switches, Write switches, Read front")
proceed = input("\nReady to configure? (y/N): ").strip().lower()
if proceed.startswith('y'):
try:
subprocess.run([sys.executable, "sp.py", "config", "--setup"], check=False)
except KeyboardInterrupt:
print("\nConfiguration cancelled.")
else:
print("\nConfiguration skipped. Run 'python sp.py config --setup' when ready.")
# 5. Success message
print("\n" + "=" * 50)
print("Setup complete!")
print("\nTry these commands:")
print(" python sp.py --help # Show all commands")
print(" python sp.py fronting # Show current fronters")
print(" python sp.py members # List all members")
print(" python sp.py switch <n> # Register a switch")
print("\nOptional: Start daemon for real-time updates (instant responses):")
print(" python sp.py daemon start # Start daemon")
print(" python sp.py daemon status # Check daemon status")
print("\nTo use 'sp' instead of 'python sp.py':")
print(" 1. Copy sp.py to a directory in your PATH (e.g., ~/bin)")
print(" 2. Make it executable: chmod +x sp.py")
print(" 3. Rename it: mv sp.py sp")
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except KeyboardInterrupt:
print("\nSetup cancelled.")
sys.exit(1)