99import sys
1010from http import HTTPStatus
1111
12- try :
13- from simple_term_menu import TerminalMenu
14- except NotImplementedError :
15- TerminalMenu = None
16-
1712from infuse_iot .api_client import Client
1813from infuse_iot .api_client .api .board import get_board_by_id , get_boards
1914from infuse_iot .api_client .api .device import (
2419from infuse_iot .api_client .models import Board , DeviceMetadata , Error , NewDevice
2520from infuse_iot .commands import InfuseCommand
2621from infuse_iot .credentials import get_api_key
22+ from infuse_iot .util .console import choose_one
2723from infuse_iot .util .soc import nrf , soc , stm
2824
2925
@@ -90,11 +86,7 @@ def create_device(self, client: Client, soc_name: str, hardware_id_str: str):
9086 sys .exit (f"Organisation query failed { orgs } " )
9187 options = [f"{ o .name :20s} ({ o .id } )" for o in orgs ]
9288
93- if TerminalMenu is None :
94- sys .exit ("Specify organisation with --organisation:\n " + "\n " .join (options ))
95-
96- terminal_menu = TerminalMenu (options )
97- idx = terminal_menu .show ()
89+ idx , _val = choose_one ("Organisation" , options )
9890 self ._org = orgs [idx ].id
9991
10092 if self ._board is None :
@@ -103,11 +95,7 @@ def create_device(self, client: Client, soc_name: str, hardware_id_str: str):
10395 sys .exit (f"Board query failed { boards } " )
10496 options = [f"{ b .name :20s} ({ b .id } )" for b in boards ]
10597
106- if TerminalMenu is None :
107- sys .exit ("Specify board with --board:\n " + "\n " .join (options ))
108-
109- terminal_menu = TerminalMenu (options )
110- idx = terminal_menu .show ()
98+ idx , _val = choose_one ("Board" , options )
11199 self ._board = boards [idx ].id
112100 board = get_board_by_id .sync (client = client , id = self ._board )
113101 if not isinstance (board , Board ):
0 commit comments