MCPcopy
hub / github.com/pallets/click / get_command

Method get_command

tests/typing/typing_aliased_group.py:11–20  ·  view source on GitHub ↗
(self, ctx: click.Context, cmd_name: str)

Source from the content-addressed store, hash-verified

9
10class AliasedGroup(click.Group):
11 def get_command(self, ctx: click.Context, cmd_name: str) -> click.Command | None:
12 rv = click.Group.get_command(self, ctx, cmd_name)
13 if rv is not None:
14 return rv
15 matches = [x for x in self.list_commands(ctx) if x.startswith(cmd_name)]
16 if not matches:
17 return None
18 elif len(matches) == 1:
19 return click.Group.get_command(self, ctx, matches[0])
20 ctx.fail(f"Too many matches: {', '.join(sorted(matches))}")
21
22 def resolve_command(
23 self, ctx: click.Context, args: list[str]

Callers

nothing calls this directly

Calls 2

list_commandsMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected