mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-27 21:16: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
|
@ -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"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
|
||||
from jrnl import time
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue