1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #ifndef CONSOLECOMMAND_H
4 #define CONSOLECOMMAND_H
6 #include "cli/clicommand.hpp"
7 #include "base/exception.hpp"
8 #include "base/scriptframe.hpp"
14 * The "console" CLI command.
18 class ConsoleCommand final : public CLICommand
21 DECLARE_PTR_TYPEDEFS(ConsoleCommand);
23 static void StaticInitialize();
25 String GetDescription() const override;
26 String GetShortDescription() const override;
27 ImpersonationLevel GetImpersonationLevel() const override;
28 void InitParameters(boost::program_options::options_description& visibleDesc,
29 boost::program_options::options_description& hiddenDesc) const override;
30 int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
32 static int RunScriptConsole(ScriptFrame& scriptFrame, const String& addr = String(),
33 const String& session = String(), const String& commandOnce = String(), const String& commandOnceFileName = String(),
34 bool syntaxOnly = false);
37 mutable boost::mutex m_Mutex;
38 mutable boost::condition_variable m_CV;
40 static void ExecuteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv,
41 bool& ready, const boost::exception_ptr& eptr, const Value& result, Value& resultOut,
42 boost::exception_ptr& eptrOut);
43 static void AutocompleteScriptCompletionHandler(boost::mutex& mutex, boost::condition_variable& cv,
44 bool& ready, const boost::exception_ptr& eptr, const Array::Ptr& result, Array::Ptr& resultOut);
47 static char *ConsoleCompleteHelper(const char *word, int state);
48 #endif /* HAVE_EDITLINE */
50 static void BreakpointHandler(ScriptFrame& frame, ScriptError *ex, const DebugInfo& di);
56 #endif /* CONSOLECOMMAND_H */