From fa278cc66821d89bd5bdcdfe5b6188ca1a9015b9 Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 13 Dec 2024 10:49:03 -0800 Subject: [PATCH] Provide helpful error when MetadataAction options have an invalid value --- internetarchive/cli/cli_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internetarchive/cli/cli_utils.py b/internetarchive/cli/cli_utils.py index 505c24aa..a4aeaac2 100644 --- a/internetarchive/cli/cli_utils.py +++ b/internetarchive/cli/cli_utils.py @@ -164,7 +164,10 @@ def __call__(self, parser, namespace, values, option_string=None): for sublist in values: if ":" not in sublist and "=" in sublist: sublist = sublist.replace("=", ":", 1) - key, value = sublist.split(":", 1) + try: + key, value = sublist.split(":", 1) + except ValueError: + parser.error(f"{option_string} must be formatted as 'KEY:VALUE'") current_dict = getattr(namespace, self.dest) if key in current_dict: