private void RunCommand(string command) { if (string.IsNullOrEmpty(command)) { return; } string[] parts = command.Split(new[] { ' ' }, 2); var commandInfo = _commandRegistry.GetCommandInfo(parts[0]); if (commandInfo == null) { Console.WriteLine($"Invalid input: \"{command}\""); return; } string commandHandlerArguments = parts.Length > 1 ? parts[1] : null; try { commandInfo.Handler(commandHandlerArguments); } catch (SomneoApiException ex) { Console.WriteLine("Somneo error: " + ex.Message); } catch (Exception ex) { Console.WriteLine("Unexpected error: " + ex); } }