mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
Fixed error related to display_format in config file
Now _display_search_results tries to source the export arg from the config file before dispaying search results.
This commit is contained in:
parent
19d579fc5c
commit
369142d641
2 changed files with 8 additions and 7 deletions
14
jrnl/jrnl.py
14
jrnl/jrnl.py
|
@ -373,20 +373,20 @@ def _change_time_search_results(args, journal, old_entries, no_prompt=False, **k
|
||||||
|
|
||||||
|
|
||||||
def _display_search_results(args, journal, **kwargs):
|
def _display_search_results(args, journal, **kwargs):
|
||||||
if args.short or args.export == "short":
|
# Get export format from config file if not provided at the command line
|
||||||
|
args.export = args.export or kwargs["config"].get("display_format")
|
||||||
|
|
||||||
|
if args.tags:
|
||||||
|
print(plugins.get_exporter("tags").export(journal))
|
||||||
|
|
||||||
|
elif args.short or args.export == "short":
|
||||||
print(journal.pprint(short=True))
|
print(journal.pprint(short=True))
|
||||||
|
|
||||||
elif args.export == "pretty":
|
elif args.export == "pretty":
|
||||||
print(journal.pprint())
|
print(journal.pprint())
|
||||||
|
|
||||||
elif args.tags:
|
|
||||||
print(plugins.get_exporter("tags").export(journal))
|
|
||||||
|
|
||||||
elif args.export:
|
elif args.export:
|
||||||
exporter = plugins.get_exporter(args.export)
|
exporter = plugins.get_exporter(args.export)
|
||||||
print(exporter.export(journal, args.filename))
|
print(exporter.export(journal, args.filename))
|
||||||
elif kwargs["config"].get("display_format"):
|
|
||||||
exporter = plugins.get_exporter(kwargs["config"]["display_format"])
|
|
||||||
print(exporter.export(journal, args.filename))
|
|
||||||
else:
|
else:
|
||||||
print(journal.pprint())
|
print(journal.pprint())
|
||||||
|
|
|
@ -16,6 +16,7 @@ def test_export_format(mock_args, export_format):
|
||||||
|
|
||||||
test_journal = jrnl.Journal.Journal
|
test_journal = jrnl.Journal.Journal
|
||||||
mock_args.export = export_format
|
mock_args.export = export_format
|
||||||
|
mock_args.tags = None
|
||||||
#fmt: off
|
#fmt: off
|
||||||
# see: https://github.com/psf/black/issues/664
|
# see: https://github.com/psf/black/issues/664
|
||||||
with mock.patch("builtins.print") as mock_spy_print, \
|
with mock.patch("builtins.print") as mock_spy_print, \
|
||||||
|
|
Loading…
Add table
Reference in a new issue