mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
deserialize function as return type
This commit is contained in:
parent
9ac21b8448
commit
bf89109525
1 changed files with 13 additions and 4 deletions
15
jrnl/args.py
15
jrnl/args.py
|
@ -17,6 +17,13 @@ from .plugins import EXPORT_FORMATS
|
||||||
from .plugins import IMPORT_FORMATS
|
from .plugins import IMPORT_FORMATS
|
||||||
from .plugins import util
|
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(':')
|
||||||
|
runtime_modifications[l] = r
|
||||||
|
return runtime_modifications
|
||||||
|
|
||||||
class WrappingFormatter(argparse.RawTextHelpFormatter):
|
class WrappingFormatter(argparse.RawTextHelpFormatter):
|
||||||
"""Used in help screen"""
|
"""Used in help screen"""
|
||||||
|
@ -323,9 +330,9 @@ def parse_args(args=[]):
|
||||||
"--config-override",
|
"--config-override",
|
||||||
dest="config_override",
|
dest="config_override",
|
||||||
action="store",
|
action="store",
|
||||||
type=json.loads,
|
type=deserialize_config_args,
|
||||||
nargs="?",
|
nargs="?",
|
||||||
default={},
|
default=None,
|
||||||
metavar="CONFIG_KV_PAIR",
|
metavar="CONFIG_KV_PAIR",
|
||||||
help="""
|
help="""
|
||||||
Override configured key-value pairs with CONFIG_KV_PAIR for this command invocation only.
|
Override configured key-value pairs with CONFIG_KV_PAIR for this command invocation only.
|
||||||
|
@ -342,4 +349,6 @@ def parse_args(args=[]):
|
||||||
num = re.compile(r"^-(\d+)$")
|
num = re.compile(r"^-(\d+)$")
|
||||||
args = [num.sub(r"-n \1", arg) for arg in args]
|
args = [num.sub(r"-n \1", arg) for arg in args]
|
||||||
|
|
||||||
return parser.parse_intermixed_args(args)
|
|
||||||
|
parsed_args = parser.parse_intermixed_args(args)
|
||||||
|
return parsed_args
|
||||||
|
|
Loading…
Add table
Reference in a new issue