Skip to content

jrnl should display an error message when using --import and --format #1990

@micahellison

Description

@micahellison

Diagnostic output

jrnl: v4.2.1
Python: 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0]
OS: Linux 5.15.0-136-generic

Current Behavior

To import a jrnl, you pipe data to a jrnl --import call. However, our documentation incorrectly states that you can specify a --format arg after --import (#1485).

Expected Behavior

Instead of being presented with a list of formats, or being told the selected format is wrong, the user should be told that the --format argument is incompatible with the --import argument.

Repro Steps

$ echo "new entry" | jrnl --import --format whatformats
usage: jrnl [--debug] [--help] [--version] [--list] [--encrypt] [--decrypt] [--import] [--template TEMPLATE] [-on DATE]
            [-today-in-history] [-month DATE] [-day DATE] [-year DATE] [-from DATE] [-to DATE] [-contains TEXT] [-and] [-starred]
            [-tagged] [-n [NUMBER]] [-not [TAG/FLAG]] [--edit] [--delete] [--change-time [DATE]] [--format TYPE] [--tags] [--short]
            [--config-override CONFIG_KV_PAIR CONFIG_KV_PAIR] [--config-file CONFIG_FILE_PATH]
            [...]
jrnl: error: argument --format: invalid choice: 'whatformats' (choose from 'boxed', 'calendar', 'dates', 'fancy', 'heatmap', 'json', 'markdown', 'md', 'pretty', 'short', 'tags', 'text', 'txt', 'xml', 'yaml')

$ echo "new entry" | jrnl --import --format text
┏━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃  AttributeError                                      ┃
┃  'NoneType' object has no attribute 'import_'        ┃
┃                                                      ┃
┃  This is probably a bug. Please file an issue at:    ┃
┃  https://github.com/jrnl-org/jrnl/issues/new/choose  ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Debug output

n/a

Other Information

It would be good to resolve #1485 in the docs while resolving this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    📌This can't go stalebugSomething isn't workingready for prOkay to start work. Feel free to ask questions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions