mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-13 15:14:50 -06:00
fix: match arg case in errors
-- d9b0a6f822f773a61bcc507d252ca46da660b70b by Eugen-Bleck <eugenbleck@gmail.com>: fix: match arg case in errors COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/724 from bl3ck:fix/preserve-arg-case-in-errors 3ac43ef2090f5e4b4158ea97cbcf16399aabe2e5 PiperOrigin-RevId: 764953570
This commit is contained in:
parent
5c2ad327bf
commit
b226a06c0b
@ -59,6 +59,19 @@ class HelpfulCommand(click.Command):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def _format_missing_arg_error(click_exception):
|
||||
"""Format the missing argument error with uppercase parameter name.
|
||||
|
||||
Args:
|
||||
click_exception: The MissingParameter exception from Click.
|
||||
|
||||
Returns:
|
||||
str: Formatted error message with uppercase parameter name.
|
||||
"""
|
||||
name = click_exception.param.name
|
||||
return f"Missing required argument: {name.upper()}"
|
||||
|
||||
def parse_args(self, ctx, args):
|
||||
"""Override the parse_args method to show help text on error.
|
||||
@ -77,8 +90,10 @@ class HelpfulCommand(click.Command):
|
||||
try:
|
||||
return super().parse_args(ctx, args)
|
||||
except click.MissingParameter as exc:
|
||||
error_message = self._format_missing_arg_error(exc)
|
||||
|
||||
click.echo(ctx.get_help())
|
||||
click.secho(f"\nError: {str(exc)}", fg="red", err=True)
|
||||
click.secho(f"\nError: {error_message}", fg="red", err=True)
|
||||
ctx.exit(2)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user