mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 13:36:14 +02:00
Clean up help screen, get rid of util.py (#1027)
* More refactoring of cli.py break up code from cli.py (now in jrnl.py) up into smaller functions get rid of export mode move --encrypt and --decrypt to commands.py clean up the help screen even more update flag name for import * reorganize code, move around lots of functions * clean up import statements * move run function out of cli and into jrnl * rename confusingly named function * move editor function into editor file * rename parse_args.py to args.py to make room for more args functions * Fix error in test suite for windows I accidentally flipped the conditional, so this fixes it. Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com> * Update app description on help screen Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
7c3abb2625
commit
631e08a557
30 changed files with 981 additions and 775 deletions
28
jrnl/prompt.py
Normal file
28
jrnl/prompt.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import getpass
|
||||
import sys
|
||||
|
||||
|
||||
def create_password(
|
||||
journal_name: str, prompt: str = "Enter password for new journal: "
|
||||
) -> str:
|
||||
while True:
|
||||
pw = getpass.getpass(prompt)
|
||||
if not pw:
|
||||
print("Password can't be an empty string!", file=sys.stderr)
|
||||
continue
|
||||
elif pw == getpass.getpass("Enter password again: "):
|
||||
break
|
||||
|
||||
print("Passwords did not match, please try again", file=sys.stderr)
|
||||
|
||||
if yesno("Do you want to store the password in your keychain?", default=True):
|
||||
from .EncryptedJournal import set_keychain
|
||||
|
||||
set_keychain(journal_name, pw)
|
||||
return pw
|
||||
|
||||
|
||||
def yesno(prompt, default=True):
|
||||
prompt = f"{prompt.strip()} {'[Y/n]' if default else '[y/N]'} "
|
||||
response = input(prompt)
|
||||
return {"y": True, "n": False}.get(response.lower().strip(), default)
|
Loading…
Add table
Add a link
Reference in a new issue