Skip to content

Commit

Permalink
Added a 'clear screen' command in CLI IMGIITRoorkee#43
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshat1276 committed Jan 5, 2025
1 parent bb75c6a commit ca72a60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Visit the **python** channel and ping `2Y` for assistance.
- `4`: Load an existing password file.
- `5`: Add a new password to the file.
- `6`: Retrieve a password from the file.
- `c`: Clear the CLI
- `q`: Quit the application.

---
Expand Down
15 changes: 12 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os #will allow user to interact with the operating system
from manager import PasswordManager
import pyperclip
import sys
Expand Down Expand Up @@ -39,7 +40,8 @@ def validate_key_loaded(pm : PasswordManager):
print("Key not loaded. Please load a key first.")
return False
return True

def clear_screen(): #Defining the clear screen function to clear the CLI.
os.system('cls' if os.name == 'nt' else 'clear') #'cls' is used to clear the terminal screen in windows, for Linux, MacOS etc. 'clear' is used
def main():
password = {
"gmail": "password1",
Expand All @@ -49,16 +51,19 @@ def main():

pm = PasswordManager()

print("""What would you like to do?
menu = """What would you like to do?
1. Create a new key
2. Load an existing key
3. Create a new password file
4. Load an existing password file
5. Add a password
6. Get a password
7. List all sites
c. Clear Screen
q. Quit
""")
"""

print(menu)

done = False
while not done:
Expand Down Expand Up @@ -104,6 +109,10 @@ def main():
print("Saved Sites:")
for site in pm.password_dict:
print(site)
elif choice == 'c': #CHECK CONDITION AND CLEAR THE CLI
clear_screen()
print(menu)
print("Cleared the screen.")
elif choice == 'q':
done = True
print("Goodbye!")
Expand Down

0 comments on commit ca72a60

Please sign in to comment.