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:
Jonathan Wren 2020-08-22 11:40:39 -07:00 committed by GitHub
parent 75730aca93
commit 7da666f423
30 changed files with 981 additions and 775 deletions

View file

@ -1,7 +1,8 @@
from jrnl.cli import parse_args
import shlex
import pytest
import shlex
from jrnl.args import parse_args
def cli_as_dict(str):
@ -14,17 +15,14 @@ def expected_args(**kwargs):
default_args = {
"contains": None,
"debug": False,
"decrypt": False,
"delete": False,
"edit": False,
"encrypt": False,
"end_date": None,
"excluded": [],
"export": False,
"input": False,
"filename": None,
"limit": None,
"on_date": None,
"output": False,
"preconfig_cmd": None,
"postconfig_cmd": None,
"short": False,
@ -66,7 +64,15 @@ def test_edit_alone():
def test_encrypt_alone():
assert cli_as_dict("--encrypt 'test.txt'") == expected_args(encrypt="test.txt")
from jrnl.commands import postconfig_encrypt
assert cli_as_dict("--encrypt") == expected_args(postconfig_cmd=postconfig_encrypt)
def test_decrypt_alone():
from jrnl.commands import postconfig_decrypt
assert cli_as_dict("--decrypt") == expected_args(postconfig_cmd=postconfig_decrypt)
def test_end_date_alone():
@ -110,15 +116,10 @@ def test_import_alone():
assert cli_as_dict("--import") == expected_args(postconfig_cmd=postconfig_import)
def test_input_flag_alone():
assert cli_as_dict("-i test.txt") == expected_args(input="test.txt")
assert cli_as_dict("-i 'lorem ipsum.txt'") == expected_args(input="lorem ipsum.txt")
def test_output_flag_alone():
assert cli_as_dict("-o test.txt") == expected_args(output="test.txt")
assert cli_as_dict("-o 'lorem ipsum.txt'") == expected_args(
output="lorem ipsum.txt"
def test_file_flag_alone():
assert cli_as_dict("--file test.txt") == expected_args(filename="test.txt")
assert cli_as_dict("--file 'lorem ipsum.txt'") == expected_args(
filename="lorem ipsum.txt"
)