1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

trezorctl: use ChoiceType for set_passphrase_source (#356)

resolves #355
This commit is contained in:
strmci 2019-01-28 16:17:02 +01:00 committed by matejcik
parent 3390422ce3
commit 4afec2f3f3

View File

@ -66,6 +66,15 @@ class ChoiceType(click.Choice):
return self.typemap[value]
CHOICE_PASSPHRASE_SOURCE_TYPE = ChoiceType(
{
"ask": proto.PassphraseSourceType.ASK,
"device": proto.PassphraseSourceType.DEVICE,
"host": proto.PassphraseSourceType.HOST,
}
)
CHOICE_RECOVERY_DEVICE_TYPE = ChoiceType(
{
"scrambled": proto.RecoveryDeviceType.ScrambledWords,
@ -253,10 +262,18 @@ def set_label(connect, label):
return device.apply_settings(connect(), label=label)
@cli.command(help="Set passphrase source.")
@click.argument("source", type=int)
@cli.command()
@click.argument("source", type=CHOICE_PASSPHRASE_SOURCE_TYPE)
@click.pass_obj
def set_passphrase_source(connect, source):
"""Set passphrase source.
Configure how to enter passphrase on Trezor Model T. The options are:
ask - always ask where to enter passphrase
device - always enter passphrase on device
host - always enter passphrase on host
"""
return device.apply_settings(connect(), passphrase_source=source)