getDeviceInfoInteractively method
Implementation
(InternetAddress ip, String username) getDeviceInfoInteractively(
CustomDevicesConfig customDevicesConfig,
String message, {
bool printSelectedDeviceInfo = false,
}) {
final deviceOptions = [
'Existing device',
'New device',
];
logger.info(message);
logger.spaces();
final deviceTypeIndex = selectIndex(
'Device Type:',
options: deviceOptions,
);
logger.spaces();
final isNewDevice = deviceTypeIndex == 1;
final (InternetAddress ip, String username) deviceInfo;
if (isNewDevice) {
logger.spaces();
logger.info("Please enter the device info:");
deviceInfo = (readDeviceIp(), readDeviceUsername());
} else {
final selectedDevice = selectDevice(customDevicesConfig);
deviceInfo = (
InternetAddress.tryParse(selectedDevice.deviceIp)!,
selectedDevice.deviceUsername
);
}
if (printSelectedDeviceInfo) {
logger.info('''
Target Device info:
Ip Address: ${deviceInfo.$1}
Username: ${deviceInfo.$2}
''');
}
return deviceInfo;
}