figments: command: rewrite command api to use Task instances instead of static functions
This commit is contained in:
@@ -126,7 +126,7 @@ SerialInput::read()
|
||||
}
|
||||
|
||||
void
|
||||
doHelp(Args& args, Print& out)
|
||||
SerialInput::doHelp(Args& args, Print& out)
|
||||
{
|
||||
out.println("Available commands:");
|
||||
auto sched = MainLoop::instance()->scheduler;
|
||||
@@ -139,14 +139,13 @@ doHelp(Args& args, Print& out)
|
||||
out.println();
|
||||
}
|
||||
|
||||
const std::vector<Command> serialCommands = {
|
||||
{"help", doHelp}
|
||||
};
|
||||
|
||||
const std::vector<Command>&
|
||||
SerialInput::commands() const
|
||||
{
|
||||
return serialCommands;
|
||||
static const std::vector<Command> _commands = {
|
||||
{"help", &SerialInput::doHelp}
|
||||
};
|
||||
return _commands;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -158,7 +157,7 @@ SerialInput::doCommand() {
|
||||
for(auto task : sched.tasks) {
|
||||
for(auto &command : task->commands()) {
|
||||
if (cmdName == command.name) {
|
||||
command.func(args, m_logPrinter);
|
||||
command.invoke(task, args, m_logPrinter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user