Overhaul of command parsing
This commit is contained in:
@@ -43,29 +43,14 @@ public:
|
||||
}
|
||||
|
||||
void do_lua_command(const util::StringVec &words) {
|
||||
if (words.size() != 2) {
|
||||
stdostream() << "lua command (lua) takes a single string" << std::endl;
|
||||
return;
|
||||
}
|
||||
const std::string &exp = words[1];
|
||||
InvocationData dummyresult;
|
||||
Invocation inv(Invocation::KIND_LUA, admin_id_, admin_id_, exp, dummyresult);
|
||||
master_->invoke(inv);
|
||||
master_->invoke(Invocation(Invocation::KIND_LUA, admin_id_, admin_id_, words[1]));
|
||||
}
|
||||
|
||||
void do_syntax_command(const util::StringVec &words) {
|
||||
stdostream() << "Syntax Error: ";
|
||||
for (int i = 1; i < int(words.size()); i++) {
|
||||
stdostream() << words[i] << " ";
|
||||
}
|
||||
stdostream() << std::endl;
|
||||
stdostream() << "Syntax Error: " << words[1] << std::endl;
|
||||
}
|
||||
|
||||
void do_quit_command(const util::StringVec &words) {
|
||||
if (words.size() != 1) {
|
||||
stdostream() << "quit command takes no arguments" << std::endl;
|
||||
return;
|
||||
}
|
||||
stop_driver();
|
||||
}
|
||||
|
||||
@@ -75,7 +60,7 @@ public:
|
||||
else if (words[0] == "syntax") do_syntax_command(words);
|
||||
else if (words[0] == "quit") do_quit_command(words);
|
||||
else {
|
||||
stdostream() << "Unknown command: " << words[0] << std::endl;
|
||||
stdostream() << "Unsupported command: " << words[0] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user