aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorWolfgang Müller2021-04-28 18:54:31 +0200
committerWolfgang Müller2021-04-28 20:15:53 +0200
commit13a43aae41cfa791fa33636b37a1db80a559ca17 (patch)
treec0d38917d9416b59285f49c93d25f147f856c45b
parent664241d9be8042f0b26515f6ffadc53f3b6e30ca (diff)
downloadquarg-13a43aae41cfa791fa33636b37a1db80a559ca17.tar.gz
main: Make --around mutually exclusive with either --after or --before
Using --around does not make much sense if there is also a match on --after or --before, since the range in --around would most certainly take precedence. Disallow this behaviour.
-rw-r--r--quarg/main.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/quarg/main.py b/quarg/main.py
index cbd5177..3927723 100644
--- a/quarg/main.py
+++ b/quarg/main.py
@@ -13,8 +13,6 @@ from quarg.database.tables import Backlog, Buffer, Network, QuasselUser, Sender
from quarg.quassel.formatter import format_from
from quarg.utils import errx
-# TODO Make --after/--before and --around mutually exclusive
-
# pylint: disable=line-too-long
cli = argparse.ArgumentParser()
cli.add_argument('query', nargs='*', help='match messages containing this query')
@@ -51,6 +49,11 @@ def get_config():
return config
+def check_args(args):
+ if args.around is not None:
+ if args.before is not None or args.after is not None:
+ errx('--around cannot be used with --after or --before')
+
def collect_predicates(args):
funs = {
'query': filters.msg_like if args.expr else filters.msg_contains,
@@ -110,6 +113,7 @@ def main():
errx('No database URL set in config file.')
args = cli.parse_args()
+ check_args(args)
engine = create_engine(config.get('Database', 'url'), echo=args.debug)
session = Session(bind=engine)