diff options
| author | Teddy Wing | 2023-11-10 19:46:39 +0100 |
|---|---|---|
| committer | Teddy Wing | 2023-11-10 19:46:39 +0100 |
| commit | 927de7cb45b6004b0c06522bf76e15c1e57c1f31 (patch) | |
| tree | ee5800dfd31ec125423e77eaef1cc3e95f761cdd | |
| parent | 665b2b3ae094b1c4efb80ae87d58e2cc0156dba9 (diff) | |
| download | cws-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-status | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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 |
