diff --git a/jrnl/config.py b/jrnl/config.py index 63de0586..7ded61ad 100644 --- a/jrnl/config.py +++ b/jrnl/config.py @@ -197,9 +197,9 @@ def get_journal_name(args, config): args.text = args.text[1:] if args.journal_name not in config["journals"]: - print("No default journal configured.", file=sys.stderr) - print(list_journals(config), file=sys.stderr) - sys.exit(1) + raise JrnlException( + Message(MsgText.NoDefaultJournal, MsgType.ERROR, { "journals": list_journals(config)}), + ) logging.debug("Using journal name: %s", args.journal_name) return args diff --git a/jrnl/messages.py b/jrnl/messages.py index 340e7b69..b38ff2aa 100644 --- a/jrnl/messages.py +++ b/jrnl/messages.py @@ -67,6 +67,8 @@ class MsgText(Enum): {template} """ + NoDefaultJournal = "No default journal configured\n{journals}" + # --- Journal status ---# JournalNotSaved = "Entry NOT saved to journal" diff --git a/jrnl/output.py b/jrnl/output.py index 8058733f..dc38b255 100644 --- a/jrnl/output.py +++ b/jrnl/output.py @@ -30,7 +30,7 @@ def list_journals(configuration): from . import config """List the journals specified in the configuration file""" - result = f"Journals defined in {config.get_config_path()}\n" + result = f"Journals defined in config ({config.get_config_path()})\n" ml = min(max(len(k) for k in configuration["journals"]), 20) for journal, cfg in configuration["journals"].items(): result += " * {:{}} -> {}\n".format(