-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
137 lines (103 loc) · 4.58 KB
/
Copy pathcli.py
File metadata and controls
137 lines (103 loc) · 4.58 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python3
"""
Sentinel CLI - Simple utilities for the email opportunity extraction system
"""
import argparse
import json
import sys
from datetime import datetime
from pathlib import Path
# Add src to path
sys.path.insert(0, str(Path(__file__).parent / "src"))
from src.utils import ProfileManager, DatabaseManager
from src.storage import StorageService
def search_opportunities(args):
"""Search opportunities by keyword."""
try:
db = DatabaseManager()
with db.connect() as conn:
conn.row_factory = db.Row
query = """
SELECT * FROM opportunities
WHERE title LIKE ? OR organization LIKE ? OR notes LIKE ?
ORDER BY priority_score DESC, processed_date DESC
LIMIT ?
"""
search_term = f"%{args.keyword}%"
cursor = conn.execute(query, (search_term, search_term, search_term, args.limit))
results = cursor.fetchall()
if not results:
print(f"No opportunities found matching '{args.keyword}'")
return
print(f"\n🔍 SEARCH RESULTS for '{args.keyword}' ({len(results)} found)")
print("=" * 60)
for i, opp in enumerate(results, 1):
print(f"\n{i}. {opp['title']}")
print(f" Organization: {opp['organization']}")
print(f" Type: {opp['opportunity_type']}")
print(f" Score: {opp['priority_score']:.2f}")
print(f" Date: {opp['processed_date']}")
if args.verbose:
print(f" Notes: {opp['notes'][:200]}...")
except Exception as e:
print(f"❌ Search failed: {e}")
return False
def update_profile(args):
"""Interactive profile update."""
try:
profile_manager = ProfileManager('config/profile.json')
profile = profile_manager.load_profile()
print("🔧 PROFILE UPDATE")
print("Current profile settings:")
print(json.dumps(profile, indent=2))
print("\nWhat would you like to update?")
print("1. Interests")
print("2. Preferred locations")
print("3. Exclusions")
choice = input("Enter choice (1-3): ").strip()
if choice == "1":
print("\nCurrent interests:", profile.get('interests', []))
new_interests = input("Enter new interests (comma-separated): ").strip()
if new_interests:
profile['interests'] = [i.strip() for i in new_interests.split(',')]
elif choice == "2":
print("\nCurrent locations:", profile.get('preferred_locations', []))
new_locations = input("Enter new locations (comma-separated): ").strip()
if new_locations:
profile['preferred_locations'] = [l.strip() for l in new_locations.split(',')]
elif choice == "3":
print("\nCurrent exclusions:", profile.get('exclusions', []))
new_exclusions = input("Enter new exclusions (comma-separated): ").strip()
if new_exclusions:
profile['exclusions'] = [e.strip() for e in new_exclusions.split(',')]
# Save updated profile
with open("config/profile.json", "w") as f:
json.dump(profile, f, indent=2)
print("✅ Profile updated successfully")
except Exception as e:
print(f"❌ Profile update failed: {e}")
def main():
"""Main CLI entry point."""
parser = argparse.ArgumentParser(
description="Sentinel CLI - Simple utilities",
formatter_class=argparse.RawDescriptionHelpFormatter
)
subparsers = parser.add_subparsers(dest='command', help='Available commands')
# Search command
search_parser = subparsers.add_parser('search', help='Search opportunities')
search_parser.add_argument('keyword', help='Search keyword')
search_parser.add_argument('--limit', type=int, default=10, help='Maximum results')
search_parser.add_argument('--verbose', action='store_true', help='Show detailed results')
# Profile command
subparsers.add_parser('profile', help='Update profile interactively')
args = parser.parse_args()
if not args.command:
parser.print_help()
return
# Execute command
if args.command == 'search':
search_opportunities(args)
elif args.command == 'profile':
update_profile(args)
if __name__ == "__main__":
main()