From 13a43aae41cfa791fa33636b37a1db80a559ca17 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Wed, 28 Apr 2021 18:54:31 +0200 Subject: 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. --- quarg/main.py | 8 ++++++-- 1 file 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) -- cgit v1.2.3-2-gb3c3