From 228d0e74ec47c9954d3a0e1da2e1c0fc6c1b518f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 3 Jun 2020 16:15:24 +0000 Subject: [PATCH] location-query: Require at least one flag Signed-off-by: Michael Tremer --- src/python/location-query.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/python/location-query.in b/src/python/location-query.in index 5f05b5c..dfdff8c 100644 --- a/src/python/location-query.in +++ b/src/python/location-query.in @@ -246,7 +246,13 @@ class CLI(object): args.family = 0 # Call function - ret = args.func(db, args) + try: + ret = args.func(db, args) + + # Catch invalid inputs + except ValueError as e: + sys.stderr.write("%s\n" % e) + ret = 2 # Return with exit code if ret: @@ -451,6 +457,9 @@ class CLI(object): if ns.anycast: flags |= location.NETWORK_FLAG_ANYCAST + if not flags: + raise ValueError(_("You must at least pass one flag")) + with self.__get_output_formatter(ns) as f: for n in db.search_networks(flags=flags, family=ns.family): f.network(n) -- 2.39.2