mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
rename
This commit is contained in:
parent
41ba0b8e65
commit
7c0772b5b6
3 changed files with 2 additions and 2 deletions
|
|
@ -1,34 +0,0 @@
|
|||
#include "StdinReader.hpp"
|
||||
|
||||
#include "logic/CommandsInterpreter.hpp"
|
||||
#include "coders/json.hpp"
|
||||
#include "debug/Logger.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
||||
static debug::Logger logger("stdin-reader");
|
||||
|
||||
static std::thread reader_thread;
|
||||
|
||||
void start_stdin_reader(cmd::CommandsInterpreter& interpreter) {
|
||||
reader_thread = std::thread([&interpreter]() {
|
||||
std::string line;
|
||||
while (std::getline(std::cin, line)) {
|
||||
if (line.empty()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
auto result = interpreter.execute(line);
|
||||
if (result.isString()) {
|
||||
logger.info() << result.asString();
|
||||
} else {
|
||||
logger.info() << json::stringify(result, true);
|
||||
}
|
||||
} catch (const std::exception& err) {
|
||||
logger.error() << err.what();
|
||||
}
|
||||
}
|
||||
});
|
||||
reader_thread.detach();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue