run method
Runs this command.
The return value is wrapped in a Future
if necessary and returned by
CommandRunner.runCommand
.
Implementation
@override
FutureOr<int>? run() {
if (customDevicesConfig.devices.isEmpty) {
throwToolExit(
'''
No devices found in config at "${customDevicesConfig.configPath}"
Before you can update a device, you need to add one first.
''',
);
}
String? deviceId;
if (globalResults!.wasParsed(deviceIdOption)) {
deviceId = globalResults!.stringArg(deviceIdOption)!;
}
String? ip;
if (argResults!.wasParsed(_ipOption)) {
ip = argResults!.stringArg(_ipOption)!;
}
if (deviceId != null && ip != null) {
if (!ip.isValidIpAddress) {
usageException('Ip address passed to this command is not valid');
}
return _updateIp(deviceId, ip);
}
return _interactiveUpdateIp(deviceId, ip);
}