using namespace icinga;
namespace po = boost::program_options;
-static ScriptFrame l_ScriptFrame;
+static ScriptFrame *l_ScriptFrame;
REGISTER_CLICOMMAND("console", ConsoleCommand);
}
{
- ObjectLock olock(l_ScriptFrame.Locals);
- BOOST_FOREACH(const Dictionary::Pair& kv, l_ScriptFrame.Locals) {
+ ObjectLock olock(l_ScriptFrame->Locals);
+ BOOST_FOREACH(const Dictionary::Pair& kv, l_ScriptFrame->Locals) {
AddSuggestion(matches, word, kv.first);
}
}
Expression *expr = ConfigCompiler::CompileText("temp", pword, false);
if (expr)
- value = expr->Evaluate(l_ScriptFrame);
+ value = expr->Evaluate(*l_ScriptFrame);
if (value.IsObjectType<Dictionary>()) {
Dictionary::Ptr dict = value;
#endif /* HAVE_EDITLINE */
String addr, session;
+ ScriptFrame scriptFrame;
+
+ l_ScriptFrame = &scriptFrame;
if (vm.count("connect")) {
addr = vm["connect"].as<std::string>();
return EXIT_FAILURE;
}
- l_ScriptFrame.Sandboxed = true;
+ scriptFrame.Sandboxed = true;
}
std::cout << "Icinga (version: " << Application::GetVersion() << ")\n";
expr = ConfigCompiler::CompileText(fileName, command, false);
if (expr) {
- Value result = expr->Evaluate(l_ScriptFrame);
+ Value result = expr->Evaluate(scriptFrame);
std::cout << ConsoleColorTag(Console_ForegroundCyan);
if (!result.IsObject() || result.IsObjectType<Array>() || result.IsObjectType<Dictionary>())
std::cout << JsonEncode(result);