@@ -559,9 +559,10 @@ def _invoke(args: tuple[str, ...]) -> None:
559559 resolved_name = resolve_command (cmd_name )
560560 try :
561561 real_typer = CommandRegistry .get_typer (resolved_name )
562- except ValueError as exc :
562+ click_cmd = get_command (real_typer )
563+ except (RuntimeError , ValueError ) as exc :
564+ click .echo (str (exc ), err = True )
563565 raise click .ClickException (str (exc )) from exc
564- click_cmd = get_command (real_typer )
565566 # Build full prog name from root (e.g. "specfact sync") so usage shows "specfact sync bridge", not "sync sync bridge"
566567 parts : list [str ] = []
567568 p = ctx .parent
@@ -626,9 +627,9 @@ def _get_real_click_group(self) -> click.Group | None:
626627 resolved_name = resolve_command (self ._lazy_cmd_name )
627628 try :
628629 real_typer = CommandRegistry .get_typer (resolved_name )
629- except ValueError :
630+ click_cmd = get_command (real_typer )
631+ except (RuntimeError , ValueError ):
630632 return None
631- click_cmd = get_command (real_typer )
632633 if isinstance (click_cmd , click .Group ):
633634 return click_cmd
634635 return None
@@ -641,9 +642,9 @@ def format_help(self, ctx: click.Context, formatter: click.HelpFormatter) -> Non
641642 resolved_name = resolve_command (self ._lazy_cmd_name )
642643 try :
643644 real_typer = CommandRegistry .get_typer (resolved_name )
644- except ValueError :
645+ click_cmd = get_command (real_typer )
646+ except (RuntimeError , ValueError ):
645647 return
646- click_cmd = get_command (real_typer )
647648 prog_name = (
648649 f"{ ctx .parent .command .name } { self ._lazy_cmd_name } "
649650 if ctx .parent and ctx .parent .command
0 commit comments