Return a list of completions for the incomplete value. Looks at the names of options and chained multi-commands. Any command could be part of a chained multi-command, so sibling commands are valid at any point during command completion. :param ctx: Invocation contex
(self, ctx: Context, incomplete: str)
| 1353 | return ctx.invoke(self.callback, **ctx.params) |
| 1354 | |
| 1355 | def shell_complete(self, ctx: Context, incomplete: str) -> list[CompletionItem]: |
| 1356 | """Return a list of completions for the incomplete value. Looks |
| 1357 | at the names of options and chained multi-commands. |
| 1358 | |
| 1359 | Any command could be part of a chained multi-command, so sibling |
| 1360 | commands are valid at any point during command completion. |
| 1361 | |
| 1362 | :param ctx: Invocation context for this command. |
| 1363 | :param incomplete: Value being completed. May be empty. |
| 1364 | |
| 1365 | .. versionadded:: 8.0 |
| 1366 | """ |
| 1367 | from click.shell_completion import CompletionItem |
| 1368 | |
| 1369 | results: list[CompletionItem] = [] |
| 1370 | |
| 1371 | if incomplete and not incomplete[0].isalnum(): |
| 1372 | for param in self.get_params(ctx): |
| 1373 | if ( |
| 1374 | not isinstance(param, Option) |
| 1375 | or param.hidden |
| 1376 | or ( |
| 1377 | not param.multiple |
| 1378 | and ctx.get_parameter_source(param.name) |
| 1379 | is ParameterSource.COMMANDLINE |
| 1380 | ) |
| 1381 | ): |
| 1382 | continue |
| 1383 | |
| 1384 | results.extend( |
| 1385 | CompletionItem(name, help=param.help) |
| 1386 | for name in [*param.opts, *param.secondary_opts] |
| 1387 | if name.startswith(incomplete) |
| 1388 | ) |
| 1389 | |
| 1390 | while ctx.parent is not None: |
| 1391 | ctx = ctx.parent |
| 1392 | |
| 1393 | if isinstance(ctx.command, Group) and ctx.command.chain: |
| 1394 | results.extend( |
| 1395 | CompletionItem(name, help=command.get_short_help_str()) |
| 1396 | for name, command in _complete_visible_commands(ctx, incomplete) |
| 1397 | if name not in ctx._protected_args |
| 1398 | ) |
| 1399 | |
| 1400 | return results |
| 1401 | |
| 1402 | @t.overload |
| 1403 | def main( |
nothing calls this directly
no test coverage detected