aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorWolfgang Müller2021-04-28 18:43:22 +0200
committerWolfgang Müller2021-04-28 20:15:53 +0200
commit664241d9be8042f0b26515f6ffadc53f3b6e30ca (patch)
tree1c0835495516e5d58b75181c116aeb0fa118ba6d
parent2c4f2670d0e7c6f8d93b1a9db9a59156d1024aab (diff)
downloadquarg-664241d9be8042f0b26515f6ffadc53f3b6e30ca.tar.gz
main: Make --joined and --no-joined mutually exclusive
Sadly we can not yet rely on BooleanOptionalAction, since that was only added in Python 3.9. Also remove the FIXME note, it seems that boolean options like this trigger a standard default setting with argparse.
-rw-r--r--quarg/main.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/quarg/main.py b/quarg/main.py
index 410306a..cbd5177 100644
--- a/quarg/main.py
+++ b/quarg/main.py
@@ -14,7 +14,6 @@ from quarg.quassel.formatter import format_from
from quarg.utils import errx
# TODO Make --after/--before and --around mutually exclusive
-# FIXME why need default=None for --joined/--no-joined?
# pylint: disable=line-too-long
cli = argparse.ArgumentParser()
@@ -29,11 +28,13 @@ cli.add_argument('-u', action='append', dest='user', help='match messages receiv
cli.add_argument('-t', action=actions.ParseMessageType, dest='msgtype', help='match messages of this message type')
cli.add_argument('-f', action=actions.ParseMessageFlag, dest='msgflag', help='match messages with this flag')
cli.add_argument('-p', action='append', dest='prefix', help='match nicks with this prefix')
-cli.add_argument('--joined', default=None, action='store_true', dest='joined', help='match messages sent to channels which are currently joined')
-cli.add_argument('--no-joined', default=None, action='store_false', dest='joined', help='match messages sent to channels which are not currently joined')
cli.add_argument('--after', action=actions.ParseDate, metavar='DATE', help='match messages sent after this date')
cli.add_argument('--before', action=actions.ParseDate, metavar='DATE', help='match messages sent before this date')
cli.add_argument('--around', action=actions.ParseAround, metavar='DATE', help='match messages sent within 12 hours of this date')
+
+joined_group = cli.add_mutually_exclusive_group()
+joined_group.add_argument('--joined', default=None, action='store_true', dest='joined', help='match messages sent to channels which are currently joined')
+joined_group.add_argument('--no-joined', default=None, action='store_false', dest='joined', help='match messages sent to channels which are not currently joined')
# pylint: enable=line-too-long
Session = sessionmaker()