mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-19 20:48:31 +02:00
make format
This commit is contained in:
parent
bf89109525
commit
3b74c2dec0
3 changed files with 23 additions and 22 deletions
15
jrnl/args.py
15
jrnl/args.py
|
@ -17,14 +17,16 @@ from .plugins import EXPORT_FORMATS
|
|||
from .plugins import IMPORT_FORMATS
|
||||
from .plugins import util
|
||||
|
||||
def deserialize_config_args(input: str) -> dict:
|
||||
_kvpairs = input.strip(' ').split(',')
|
||||
runtime_modifications = {}
|
||||
for _p in _kvpairs:
|
||||
l,r = _p.strip().split(':')
|
||||
|
||||
def deserialize_config_args(input: str) -> dict:
|
||||
_kvpairs = input.strip(" ").split(",")
|
||||
runtime_modifications = {}
|
||||
for _p in _kvpairs:
|
||||
l, r = _p.strip().split(":")
|
||||
runtime_modifications[l] = r
|
||||
return runtime_modifications
|
||||
|
||||
|
||||
|
||||
class WrappingFormatter(argparse.RawTextHelpFormatter):
|
||||
"""Used in help screen"""
|
||||
|
||||
|
@ -349,6 +351,5 @@ def parse_args(args=[]):
|
|||
num = re.compile(r"^-(\d+)$")
|
||||
args = [num.sub(r"-n \1", arg) for arg in args]
|
||||
|
||||
|
||||
parsed_args = parser.parse_intermixed_args(args)
|
||||
return parsed_args
|
||||
|
|
|
@ -85,7 +85,7 @@ def test_override_configured_colors(
|
|||
):
|
||||
mock_load_or_install.return_value = minimal_config
|
||||
|
||||
cli_args = shlex.split('--config-override colors.body:blue')
|
||||
cli_args = shlex.split("--config-override colors.body:blue")
|
||||
parser = parse_args(cli_args)
|
||||
assert "colors.body" in parser.config_override.keys()
|
||||
with mock.patch.object(
|
||||
|
|
|
@ -206,35 +206,35 @@ def test_version_alone():
|
|||
|
||||
assert cli_as_dict("--version") == expected_args(preconfig_cmd=preconfig_version)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"input_str",
|
||||
[
|
||||
'editor:"nano", colors.title:blue, default:"/tmp/egg.txt"',
|
||||
'editor:"vi -c startinsert", colors.title:blue, default:"/tmp/egg.txt"',
|
||||
'editor:"nano", colors.title:blue, default:"/tmp/eg\ g.txt"'
|
||||
]
|
||||
'editor:"nano", colors.title:blue, default:"/tmp/eg\ g.txt"',
|
||||
],
|
||||
)
|
||||
def test_deserialize_config_args(input_str):
|
||||
from jrnl.args import deserialize_config_args
|
||||
|
||||
def test_deserialize_config_args(input_str):
|
||||
from jrnl.args import deserialize_config_args
|
||||
|
||||
runtime_config = deserialize_config_args(input_str)
|
||||
assert runtime_config.__class__ == dict
|
||||
assert "editor" in runtime_config.keys()
|
||||
assert "colors.title" in runtime_config.keys()
|
||||
assert "default" in runtime_config.keys()
|
||||
|
||||
|
||||
def test_editor_override():
|
||||
|
||||
parsed_args = cli_as_dict('--config-override editor:"nano"')
|
||||
assert parsed_args == expected_args(
|
||||
config_override={"editor": "nano"}
|
||||
)
|
||||
assert parsed_args == expected_args(config_override={"editor": "nano"})
|
||||
|
||||
|
||||
def test_color_override():
|
||||
assert cli_as_dict(
|
||||
'--config-override colors.body:blue'
|
||||
) == expected_args(config_override={"colors.body": "blue"})
|
||||
assert cli_as_dict("--config-override colors.body:blue") == expected_args(
|
||||
config_override={"colors.body": "blue"}
|
||||
)
|
||||
|
||||
|
||||
def test_multiple_overrides():
|
||||
|
@ -243,9 +243,9 @@ def test_multiple_overrides():
|
|||
)
|
||||
assert parsed_args == expected_args(
|
||||
config_override={
|
||||
'colors.title': 'green',
|
||||
'journal.scratchpad': '/tmp/scratchpad',
|
||||
'editor': 'nano',
|
||||
"colors.title": "green",
|
||||
"journal.scratchpad": "/tmp/scratchpad",
|
||||
"editor": "nano",
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue