MCPcopy
hub / github.com/fastapi/typer / get_command

Function get_command

typer/main.py:1173–1208  ·  view source on GitHub ↗
(typer_instance: Typer)

Source from the content-addressed store, hash-verified

1171
1172
1173def get_command(typer_instance: Typer) -> _click.Command:
1174 if typer_instance._add_completion:
1175 click_install_param, click_show_param = get_install_completion_arguments()
1176 if (
1177 typer_instance.registered_callback
1178 or typer_instance.info.callback
1179 or typer_instance.registered_groups
1180 or len(typer_instance.registered_commands) > 1
1181 ):
1182 # Create a Group
1183 click_command: _click.Command = get_group(typer_instance)
1184 if typer_instance._add_completion:
1185 click_command.params.append(click_install_param)
1186 click_command.params.append(click_show_param)
1187 return click_command
1188 elif len(typer_instance.registered_commands) == 1:
1189 # Create a single Command
1190 single_command = typer_instance.registered_commands[0]
1191
1192 if not single_command.context_settings and not isinstance(
1193 typer_instance.info.context_settings, DefaultPlaceholder
1194 ):
1195 single_command.context_settings = typer_instance.info.context_settings
1196
1197 click_command = get_command_from_info(
1198 single_command,
1199 pretty_exceptions_short=typer_instance.pretty_exceptions_short,
1200 rich_markup_mode=typer_instance.rich_markup_mode,
1201 )
1202 if typer_instance._add_completion:
1203 click_command.params.append(click_install_param)
1204 click_command.params.append(click_show_param)
1205 return click_command
1206 raise RuntimeError(
1207 "Could not get a command for this Typer instance"
1208 ) # pragma: no cover
1209
1210
1211def solve_typer_info_help(typer_info: TyperInfo) -> str:

Callers 1

__call__Method · 0.85

Calls 3

get_groupFunction · 0.85
get_command_from_infoFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…