bucky.cli.typer_utils#

Provide utils to typer to enable click-like invoke.

Module Contents#

Functions#

callback_to_click_command(typer_instance: typer.Typer, callback: Union[Callable[Ellipsis, T], click.Command]) → Union[Callable[Ellipsis, T], click.Command]

Return the click.Command object for a given callable, if it is registered under the given Typer instance.

find_command_info(typer_instance: typer.Typer, callback: Callable) → Optional[typer.models.CommandInfo]

Return a CommandInfo that is contained within a Typer instance.

find_typer_info(typer_instance: typer.Typer, callback: Callable) → Optional[typer.models.TyperInfo]

Return a TyperInfo that is contained within a Typer instance.

forward(typer_instance: typer.Typer, callback: Callable[Ellipsis, T], *args, **kwargs) → T

Forward a callable that is a registered command or subcommand of the typer_instance.

invoke(typer_instance: typer.Typer, callback: Callable[Ellipsis, T], *args, **kwargs) → T

Invoke a callable that is a registered command or subcommand of the typer_instance.

Attributes#

T

bucky.cli.typer_utils.T[source]#
bucky.cli.typer_utils.callback_to_click_command(typer_instance: typer.Typer, callback: Union[Callable[Ellipsis, T], click.Command]) Union[Callable[Ellipsis, T], click.Command][source]#

Return the click.Command object for a given callable, if it is registered under the given Typer instance.

If the callback is not a registered command, just returns the callback.

bucky.cli.typer_utils.find_command_info(typer_instance: typer.Typer, callback: Callable) Optional[typer.models.CommandInfo][source]#

Return a CommandInfo that is contained within a Typer instance.

bucky.cli.typer_utils.find_typer_info(typer_instance: typer.Typer, callback: Callable) Optional[typer.models.TyperInfo][source]#

Return a TyperInfo that is contained within a Typer instance.

bucky.cli.typer_utils.forward(typer_instance: typer.Typer, callback: Callable[Ellipsis, T], *args, **kwargs) T[source]#

Forward a callable that is a registered command or subcommand of the typer_instance.

See click.Context.forward.

bucky.cli.typer_utils.invoke(typer_instance: typer.Typer, callback: Callable[Ellipsis, T], *args, **kwargs) T[source]#

Invoke a callable that is a registered command or subcommand of the typer_instance.

See click.Context.invoke.