Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The -not option with no arguments now outputs error instead of stack trace #1466

Merged
merged 1 commit into from May 7, 2022

Conversation

apainintheneck
Copy link
Contributor

Checklist

  • I have read the contributing doc.
  • I have included a link to the relevant issue number.
  • I have checked to ensure there aren't other open pull requests
    for the same issue.
  • I have written new tests for these changes, as needed.

This is related to the bug discussed in #1350. By setting nargs=1 argparse now automatically checks to see if that you've entered the right number of arguments and that prevents [None] from being passed to interior methods. As a result, the user gets an argument error when trying to pass too few arguments.

usage: jrnl [--debug] [--help] [--version] [--list] [--encrypt] [--decrypt] [--import] [-on DATE] [-today-in-history] [-month DATE] [-day DATE] [-year DATE]
            [-from DATE] [-to DATE] [-contains TEXT] [-and] [-starred] [-n [NUMBER]] [-not TAG] [--edit] [--delete] [--format TYPE] [--tags] [--short]
            [--config-override CONFIG_KV_PAIR CONFIG_KV_PAIR] [--config-file CONFIG_FILE_PATH]
            [...]
jrnl: error: argument -not: expected 1 argument

Fixes #1350.

@wren wren added the bug Something isn't working label May 7, 2022
@wren wren changed the title Fixed -not option with no arguments bug The -not option with no arguments now outputs error instead of stack trace May 7, 2022
Copy link
Member

@wren wren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thank you!

@wren wren merged commit 8458cdb into jrnl-org:develop May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'-not -contains x' raises an AttributeError exception
2 participants