aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-11-10 19:46:39 +0100
committerTeddy Wing2023-11-10 19:46:39 +0100
commit927de7cb45b6004b0c06522bf76e15c1e57c1f31 (patch)
treeee5800dfd31ec125423e77eaef1cc3e95f761cdd
parent665b2b3ae094b1c4efb80ae87d58e2cc0156dba9 (diff)
downloadcws-status-927de7cb45b6004b0c06522bf76e15c1e57c1f31.tar.bz2
cws-status: Show error message when regex input does not match items
When no extension items were matched by the input regex, we previously ran into a runtime error that wasn't obvious. Instead print an error message explaining what the problem is.
-rw-r--r--cws-status5
1 files changed, 5 insertions, 0 deletions
diff --git a/cws-status b/cws-status
index 2434b57..17e4213 100644
--- a/cws-status
+++ b/cws-status
@@ -32,6 +32,7 @@ from lxml import html
VERSION = '0.0.3'
EX_USAGE = 64
+EX_DATAERR = 65
EX_NOUSER = 67
@@ -119,6 +120,10 @@ for i, name in enumerate(item_names_versions):
if re.search(regex, name):
matched_extensions.append((name, item_statuses[i]))
+if len(matched_extensions) == 0:
+ print(f"error: no extensions matched the query: '{regex}'", file=sys.stderr)
+ sys.exit(EX_DATAERR)
+
name_width = max([len(pair[0]) for pair in matched_extensions])
column_padding = 7