"echo":"echo <string content> ( 'string_content' = any text to be echoed )",
"dbg":"dbg ( Prints a debug output of the manager's state )",
"list":"list [ <label> <password> ](Prints the passwords currently stored 'label' = the password you want to decrypt)",
"save":"save - Saves the state to the file originally inputted.",# TODO: make it possible to save to a new file
"save":"save <filename> - Saves the state to the file originally inputted or the file provided.",
"drop":"drop <label> - deletes the selected label from the list of passwords. This can be undone with the 'undo' command, however if 'drop' is used on an already deleted password, the password is removed forever from the database.",
"undo":"undo - undoes the latest deletion/modification",
"history":"history - prints all the deleted passwords",
...
...
@@ -306,7 +306,9 @@ class State:
'<p.label>,<p.encrypted_password>' <-- same format as caesar, just in a different section
<end>
"""
defsave(self):
defsave(self,filepath=None):
iffilepathisNone:
filepath=self.filepath
content=self.head+"\n"
content+=f"{self.rsa_key}"+"\n"
forl,pinself.passwords.items():
...
...
@@ -324,7 +326,7 @@ class State:
content+=f"rm({l}),{p.encrypt()}\n"
else:
content+=f"{l},{p.encrypt()}\n"
file=open(self.filepath,'w')
file=open(filepath,'w')
file.write(content)
file.close()
...
...
@@ -461,9 +463,12 @@ def main():
elifcommand=="dbg":
print(vars(state))
elifcommand=="save"orcommand=="s":
file=None
iflen(args)>1:
file=args[1]
try:
state.save()
print(f"State saved to {filepath}!")
state.save(file)
print(f"State saved to {file if file is not None else state.filepath}!")
except:
print("There was an error saving, maybe back up your stuff now. Sorry")