| 68 | |
| 69 | def _list_option(type_: _RemoteControlType): |
| 70 | def callback(ctx: click.Context, param, value) -> None: |
| 71 | if not value: |
| 72 | return |
| 73 | choices = _get_commands_of_type(type_) |
| 74 | |
| 75 | formatter = click.HelpFormatter() |
| 76 | |
| 77 | with formatter.section(f'{type_.capitalize()} Commands'): |
| 78 | command_list = [] |
| 79 | for command_name, info in choices.items(): |
| 80 | if info.signature: |
| 81 | command_preview = f'{command_name} {info.signature}' |
| 82 | else: |
| 83 | command_preview = command_name |
| 84 | command_list.append((command_preview, info.help)) |
| 85 | formatter.write_dl(command_list) |
| 86 | ctx.obj.echo(formatter.getvalue(), nl=False) |
| 87 | ctx.exit() |
| 88 | |
| 89 | return click.option( |
| 90 | '--list', |