From 8458cdb06f4cf17602f3d9c4a1f6333518167b8a Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 7 May 2022 12:19:37 -0700 Subject: [PATCH] Fixed -not option with no arguments bug (#1466) --- jrnl/args.py | 4 ++-- tests/unit/test_parse_args.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jrnl/args.py b/jrnl/args.py index dba5a749..6a2a86ea 100644 --- a/jrnl/args.py +++ b/jrnl/args.py @@ -243,10 +243,10 @@ def parse_args(args=[]): reading.add_argument( "-not", dest="excluded", - nargs="?", + nargs=1, default=[], metavar="TAG", - action="append", + action="extend", help="Exclude entries with this tag", ) diff --git a/tests/unit/test_parse_args.py b/tests/unit/test_parse_args.py index f408c9aa..aadc6684 100644 --- a/tests/unit/test_parse_args.py +++ b/tests/unit/test_parse_args.py @@ -88,6 +88,12 @@ def test_end_date_alone(): assert expected == cli_as_dict("-to 2020-01-01") +def test_not_empty(): + with pytest.raises(SystemExit) as wrapped_e: + cli_as_dict("-not") + assert wrapped_e.value.code == 2 + + def test_not_alone(): assert cli_as_dict("-not test") == expected_args(excluded=["test"])