diff --git a/jrnl/plugins/__init__.py b/jrnl/plugins/__init__.py index ad174f0b..6ac1c2f9 100644 --- a/jrnl/plugins/__init__.py +++ b/jrnl/plugins/__init__.py @@ -10,7 +10,7 @@ from .markdown_exporter import MarkdownExporter from .tag_exporter import TagExporter from .dates_exporter import DatesExporter from .template_exporter import __all__ as template_exporters -from .text_exporter import TextExporter +from .text_exporter import TextExporter, PrettyExporter from .xml_exporter import XMLExporter from .yaml_exporter import YAMLExporter @@ -23,6 +23,7 @@ __exporters = [ XMLExporter, YAMLExporter, FancyExporter, + PrettyExporter ] + template_exporters __importers = [JRNLImporter] diff --git a/jrnl/plugins/text_exporter.py b/jrnl/plugins/text_exporter.py index 7714606c..2088e2bd 100644 --- a/jrnl/plugins/text_exporter.py +++ b/jrnl/plugins/text_exporter.py @@ -9,7 +9,7 @@ import unicodedata from jrnl.color import ERROR_COLOR from jrnl.color import RESET_COLOR - +from jrnl.Entry import Entry class TextExporter: """This Exporter can convert entries and journals into text files.""" @@ -77,3 +77,10 @@ class TextExporter: return cls.write_file(journal, output) else: return cls.export_journal(journal) + + +class PrettyExporter(TextExporter): + names = ["pretty"] + @classmethod + def export_entry(cls, entry: Entry): + return entry.pprint() \ No newline at end of file diff --git a/tests/test_parse_args.py b/tests/test_parse_args.py index feb31d07..7fa062a6 100644 --- a/tests/test_parse_args.py +++ b/tests/test_parse_args.py @@ -116,8 +116,14 @@ def test_not_interspersed(): assert cli_as_dict("two -not one two -not three two") == result -def test_export_alone(): - assert cli_as_dict("--export json") == expected_args(export="json") +@pytest.mark.parametrize( + "export_formats", + [ + "fancy","pretty","json","markdown","xml","txt" + ] +) +def test_export_alone(export_formats): + assert cli_as_dict("--export %s"%export_formats) == expected_args(export=export_formats) def test_import_alone():