mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
python/trezorctl: nicer output for list-devices
This commit is contained in:
parent
b801f1a9cf
commit
af05e0927f
@ -203,15 +203,29 @@ def print_result(res, is_json, **kwargs):
|
|||||||
click.echo(res)
|
click.echo(res)
|
||||||
|
|
||||||
|
|
||||||
|
def format_device_name(features):
|
||||||
|
model = features.model or "1"
|
||||||
|
if features.bootloader_mode:
|
||||||
|
return "Trezor {} bootloader".format(model)
|
||||||
|
|
||||||
|
label = features.label or "(unnamed)"
|
||||||
|
return "{} [Trezor {}, {}]".format(label, model, features.device_id)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Common functions
|
# Common functions
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
@cli.command(name="list")
|
@cli.command(name="list")
|
||||||
def list_devices():
|
@click.option("-n", "no_resolve", is_flag=True, help="Do not resolve Trezor names")
|
||||||
|
def list_devices(no_resolve):
|
||||||
"""List connected Trezor devices."""
|
"""List connected Trezor devices."""
|
||||||
return enumerate_devices()
|
if no_resolve:
|
||||||
|
return enumerate_devices()
|
||||||
|
|
||||||
|
for transport in enumerate_devices():
|
||||||
|
client = TrezorClient(transport, ui=ui.ClickUI())
|
||||||
|
click.echo("{} - {}".format(transport, format_device_name(client.features)))
|
||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
|
Loading…
Reference in New Issue
Block a user