From d71eb5ab57fa787effa4d94759a27840ec2bc5dd Mon Sep 17 00:00:00 2001 From: fubuloubu <3859395+fubuloubu@users.noreply.github.com> Date: Fri, 21 Feb 2025 20:16:23 -0500 Subject: [PATCH] refactor(cli): display empty if there are no options --- silverback/_click_ext.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/silverback/_click_ext.py b/silverback/_click_ext.py index 609aee63..13cdbba0 100644 --- a/silverback/_click_ext.py +++ b/silverback/_click_ext.py @@ -34,9 +34,11 @@ def parse_globbed_arg(selection: str, collection: dict[str, Any]) -> list[Any]: elif matches := fnmatch.filter(collection, selection): return [collection[match] for match in matches] + elif choices := "', '".join(collection): + raise click.BadArgumentUsage(f"Selection '{selection}' should match one of: '{choices}'") + else: - choices = "', '".join(collection) - raise click.BadArgumentUsage(f"Selection '{selection}' does not match any of: '{choices}'") + raise click.BadArgumentUsage("No choices available") def cls_import_callback(ctx, param, cls_name):