-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
52 lines (42 loc) · 1.74 KB
/
cli.py
File metadata and controls
52 lines (42 loc) · 1.74 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
from auth import verify_master_password
from storage import save_password, get_password, delete_password, list_services, clear_all_passwords
import argparse
def main():
print("🔐 Welcome to SecurePass - Your Local Password Manager")
if not verify_master_password():
return
parser = argparse.ArgumentParser()
parser.add_argument("command", help="add, get, delete, list, or clear")
args = parser.parse_args()
if args.command == "add":
service = input("Enter the site/service name: ")
username = input("Enter the username: ")
password = input("Enter the password: ")
save_password(service, username, password)
print("✅ Password saved successfully!")
elif args.command == "get":
service = input("Enter the site/service name to retrieve: ")
entry = get_password(service)
if entry:
print(f"Username: {entry['username']}")
print(f"Password: {entry['password']}")
else:
print("❌ No entry found for that service.")
elif args.command == "delete":
service = input("Enter the site/service name to delete: ")
if delete_password(service):
print("🗑️ Password deleted successfully.")
else:
print("❌ No entry found to delete.")
elif args.command == "list":
list_services()
elif args.command == "clear":
confirm = input("⚠️ Are you sure you want to delete ALL saved entries? (yes/no): ")
if confirm.lower() == "yes":
clear_all_passwords()
else:
print("❎ Operation cancelled.")
else:
print("❗ Oops! Unknown command. Try: add, get, delete, list, or clear.")
if __name__ == "__main__":
main()