8000 fix: match arg case in errors · google/adk-python@b226a06 · GitHub
[go: up one dir, main page]

Skip to content

Commit b226a06

Browse files
bl3ckcopybara-github
authored andcommitted
fix: match arg case in errors
-- d9b0a6f by Eugen-Bleck <eugenbleck@gmail.com>: fix: match arg case in errors COPYBARA_INTEGRATE_REVIEW=#724 from bl3ck:fix/preserve-arg-case-in-errors 3ac43ef PiperOrigin-RevId: 764953570
1 parent 5c2ad32 commit b226a06

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/google/adk/cli/cli_tools_click.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ class HelpfulCommand(click.Command):
5959

6060
def __init__(self, *args, **kwargs):
6161
super().__init__(*args, **kwargs)
62+
63+
@staticmethod
64+
def _format_missing_arg_error(click_exception):
65+
"""Format the missing argument error with uppercase parameter name.
66+
67+
Args:
68+
click_exception: The MissingParameter exception from Click.
69+
70+
Returns:
71+
str: Formatted error message with uppercase parameter name.
72+
"""
73+
name = click_exception.param.name
74+
return f"Missing required argument: {name.upper()}"
6275

6376
def parse_args(self, ctx, args):
6477
"""Override the parse_args method to show help text on error.
@@ -77,8 +90,10 @@ def parse_args(self, ctx, args):
7790
try:
7891
return super().parse_args(ctx, args)
7992
except click.MissingParameter as exc:
93+
error_message = self._format_missing_arg_error(exc)
94+
8095
click.echo(ctx.get_help())
81-
click.secho(f"\nError: {str(exc)}", fg="red", err=True)
96+
click.secho(f"\nError: {error_message}", fg="red", err=True)
8297
ctx.exit(2)
8398

8499

0 commit comments

Comments
 (0)
0