Skip to content

Commit

Permalink
refine pwd_keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
minghu6 committed Jul 24, 2018
1 parent 3228958 commit 216460b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions minghu6/tools/pwd_keeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"""PwdKeeper
a small password keeper, query or add username-password by interactive
list (alias ls l) #list all label
query <label>
add <label> <username> <password>
query, ? <label>
add, + <label> <username> <password>
del-account <label> <username-todel>
del-label <old-label> <new-label>
update-account <label> <username> <new-password>
update-label <old-label> <new-label>
q # quit
? # for help
q! # quit
h # for help
Usage:
pwd_keeper <path> [--password=<master-pwd>] [--username=<username>]
Expand Down Expand Up @@ -143,11 +143,14 @@ def main(path, pwd, check_username=False, username=None):
interactive_help = split_blankline(__doc__)[0]
while True:
input_result = input(base_prompt).strip() # STRIP !!
if 'q' in input_result:

first_elem = split_whitespace(input_result)[0]

if 'q!' in input_result:
return

try:
if input_result.startswith('query'):
if first_elem in ('query', '?'):
label = split_whitespace(input_result)[1]
all_match = pwd_keeper.query_account(label)
if all_match is None:
Expand Down Expand Up @@ -180,7 +183,7 @@ def main(path, pwd, check_username=False, username=None):
desensitization_pwd(pwd))
)

elif input_result.startswith('add'):
elif first_elem in ('add', '+'):
_, label, username, password = split_whitespace(input_result)
pwd_keeper.add_account(label, username, password)

Expand All @@ -203,7 +206,7 @@ def main(path, pwd, check_username=False, username=None):
elif input_result.startswith('list') or input_result == 'ls' or input_result == 'l':
[color.print_info(label) for label in pwd_keeper.get_labels() if pwd_keeper]

elif input_result.startswith('?'):
elif input_result in ('h', 'help'):
color.print_info(interactive_help)
elif input_result == '':
pass
Expand Down

0 comments on commit 216460b

Please sign in to comment.