Make luaconsole even easier to use.

This commit is contained in:
2021-11-04 14:49:25 -04:00
parent 0a00ecaaa8
commit 7966707450
4 changed files with 50 additions and 55 deletions

View File

@@ -32,9 +32,13 @@ public:
// Establish a connection to the server.
channel_ = new_outgoing_channel("localhost:8085");
// Set the console prompt
get_stdio_channel()->set_prompt(console_.get_prompt());
}
void do_command(const util::StringVec &words) {
if (words.empty()) return;
stdostream() << "Command: ";
for (const std::string &word : words) {
stdostream() << word << " ";
@@ -48,12 +52,8 @@ public:
std::string line = get_stdio_channel()->in()->readline();
if (line == "") break;
console_.add(line);
const util::StringVec &words = console_.words();
if (!words.empty()) {
do_command(words);
console_.clear();
}
get_stdio_channel()->out()->write_bytes(console_.get_prompt());
get_stdio_channel()->set_prompt(console_.get_prompt());
do_command(console_.get_command());
}
// Check for communication from server..