-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
executable file
·59 lines (45 loc) · 1.52 KB
/
app.py
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
#!/usr/bin/env python3
import typer
from PasswordManager import PasswordManager
app = typer.Typer()
password_manager = PasswordManager()
@app.command()
def init():
if password_manager.init_app():
typer.echo('Password manager initialized in home directory')
else:
typer.echo('Password manager already initialized')
@app.command()
def add(site: str, username: str, pw: str):
main_password = typer.prompt('Enter your password: ', hide_input=True)
r = password_manager.add_password(site, username, pw, main_password)
if not r:
typer.echo("Error: Password not added")
else:
typer.echo("Password added")
@app.command()
def delete(site: str, username: str, main_password: str):
r = password_manager.delete_password(site, username, main_password)
if not r:
typer.echo("Error: Password not deleted")
else:
typer.echo("Password deleted")
@app.command()
def list_all():
list_saved_pw = password_manager.get_list_password_file_path()
if len(list_saved_pw) == 0:
typer.echo("No password saved")
else:
typer.echo("List of saved passwords:")
for pw in list_saved_pw:
typer.echo(f' {pw}')
@app.command()
def get(site: str, username: str):
main_password = typer.prompt('Enter your password: ', hide_input=True)
r = password_manager.get_password(site, username, main_password)
if not r:
typer.echo("Error: Password not found")
else:
typer.echo(f'pass : {r}')
if __name__ == "__main__":
app()