run method

  1. @override
void run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
void run() async {
  Loggy.initLoggy(
    logPrinter: const PrettyPrinter(
      showColors: false,
    ),
    logOptions: OnvifUtil.convertToLogOptions(globalResults!['log-level']),
  );

  final server = await serve(
    DevicesController().handler,
    argResults!['bind-ip'],
    int.parse(argResults!['port']),
  );

  if (argResults!['bind-ip'] == _defaultIp) {
    final interfaces = await NetworkInterface.list();

    for (var interface in interfaces) {
      for (var addr in interface.addresses) {
        loggy.info('Serving at http://${addr.address}:${server.port}');
      }
    }
  } else {
    loggy.info('Serving at http://${server.address.host}:${server.port}');
  }
}