Allow multiple command per line separated by ;

This commit is contained in:
hsaturn
2021-04-11 19:19:06 +02:00
parent c59bddfd39
commit 1cfb5cfab1

View File

@@ -384,8 +384,15 @@ void loop()
last_cmd=cmd; last_cmd=cmd;
if (cmd.substr(0,3)!="set") replaceVars(cmd); if (cmd.substr(0,3)!="set") replaceVars(cmd);
while(cmd.length()) while(cmd.length())
{ {
std::string cmd_end;
if (cmd.find(';') != std::string::npos)
{
cmd_end = cmd;
cmd = getword(cmd_end,"",';');
}
MqttError retval = MqttOk; MqttError retval = MqttOk;
std::string s; std::string s;
@@ -619,7 +626,7 @@ void loop()
Serial << "IP: " << WiFi.localIP() << endl; Serial << "IP: " << WiFi.localIP() << endl;
else if (compare(s,"help")) else if (compare(s,"help"))
{ {
Serial << "syntax:" << endl; Serial << "syntax: instr; instr; ..." << endl;
Serial << " MqttBroker:" << endl; Serial << " MqttBroker:" << endl;
Serial << " broker {name} {port} : create a new broker" << endl; Serial << " broker {name} {port} : create a new broker" << endl;
Serial << endl; Serial << endl;
@@ -654,6 +661,11 @@ void loop()
{ {
Serial << "## ERROR " << retval << endl; Serial << "## ERROR " << retval << endl;
} }
if (cmd_end.length())
{
cmd = cmd_end;
cmd_end = "";
}
} }
} }
else else