bindings: initial support for running external commands
This commit is contained in:
@@ -147,6 +147,14 @@ Action *parseActionLine(const std::string &line, F error)
|
||||
else
|
||||
error() << "unknown action passed to require_runnable: '" << arg << "'\n";
|
||||
}
|
||||
else if (action_name == "run_external_command")
|
||||
{
|
||||
std::string command = getEnclosedString(line, '"', '"', 0);
|
||||
if (!command.empty())
|
||||
result = new RunExternalCommand(std::move(command));
|
||||
else
|
||||
error() << "empty command passed to run_external_command\n";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -36,3 +36,9 @@ bool RequireScreen::canBeRun() const
|
||||
{
|
||||
return Global::myScreen->type() == m_screen_type;
|
||||
}
|
||||
|
||||
void RunExternalCommand::Run()
|
||||
{
|
||||
GNUC_UNUSED int res;
|
||||
res = std::system(m_command.c_str());
|
||||
}
|
||||
|
||||
@@ -64,4 +64,16 @@ private:
|
||||
ScreenType m_screen_type;
|
||||
};
|
||||
|
||||
struct RunExternalCommand : public Action
|
||||
{
|
||||
RunExternalCommand(std::string command)
|
||||
: Action(aMacroUtility, ""), m_command(command) { }
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
|
||||
private:
|
||||
std::string m_command;
|
||||
};
|
||||
|
||||
#endif // NCMPCPP_MACRO_UTILITIES_H
|
||||
|
||||
Reference in New Issue
Block a user