mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Add user-friendly message when missing importer
This commit is contained in:
parent
eb5fe6fef1
commit
1609ea6bf8
2 changed files with 16 additions and 1 deletions
|
@ -76,7 +76,17 @@ def postconfig_import(args: argparse.Namespace, config: dict, **_) -> int:
|
||||||
journal = open_journal(args.journal_name, config)
|
journal = open_journal(args.journal_name, config)
|
||||||
|
|
||||||
format = args.export if args.export else "jrnl"
|
format = args.export if args.export else "jrnl"
|
||||||
get_importer(format).import_(journal, args.filename)
|
|
||||||
|
if (importer := get_importer(format)) is None:
|
||||||
|
raise JrnlException(
|
||||||
|
Message(
|
||||||
|
MsgText.ImporterNotFound,
|
||||||
|
MsgStyle.ERROR,
|
||||||
|
{"format": format},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
importer.import_(journal, args.filename)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
@ -266,6 +266,11 @@ class MsgText(Enum):
|
||||||
{count} imported to {journal_name} journal
|
{count} imported to {journal_name} journal
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ImporterNotFound = """
|
||||||
|
No importer found for file type '{format}'.
|
||||||
|
'{format}' is likely to be an export-only format.
|
||||||
|
"""
|
||||||
|
|
||||||
# --- Color --- #
|
# --- Color --- #
|
||||||
InvalidColor = "{key} set to invalid color: {color}"
|
InvalidColor = "{key} set to invalid color: {color}"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue