icinga2/lib/cli/consolecommand.hpp

61 lines
1.7 KiB
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2014-11-23 12:35:13 +01:00
#ifndef CONSOLECOMMAND_H
#define CONSOLECOMMAND_H
2014-11-23 12:35:13 +01:00
#include "cli/clicommand.hpp"
#include "base/exception.hpp"
#include "base/scriptframe.hpp"
#include "base/tlsstream.hpp"
#include "remote/url.hpp"
2014-11-23 12:35:13 +01:00
namespace icinga
{
/**
* The "console" CLI command.
2014-11-23 12:35:13 +01:00
*
* @ingroup cli
*/
2018-01-04 06:11:04 +01:00
class ConsoleCommand final : public CLICommand
2014-11-23 12:35:13 +01:00
{
public:
DECLARE_PTR_TYPEDEFS(ConsoleCommand);
2014-11-23 12:35:13 +01:00
static void StaticInitialize();
String GetDescription() const override;
String GetShortDescription() const override;
ImpersonationLevel GetImpersonationLevel() const override;
void InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
static int RunScriptConsole(ScriptFrame& scriptFrame, const String& connectAddr = String(),
const String& session = String(), const String& commandOnce = String(), const String& commandOnceFileName = String(),
bool syntaxOnly = false);
private:
mutable boost::mutex m_Mutex;
mutable boost::condition_variable m_CV;
static Shared<AsioTlsStream>::Ptr Connect();
static Value ExecuteScript(const String& session, const String& command, bool sandboxed);
static Array::Ptr AutoCompleteScript(const String& session, const String& command, bool sandboxed);
static Dictionary::Ptr SendRequest();
#ifdef HAVE_EDITLINE
static char *ConsoleCompleteHelper(const char *word, int state);
#endif /* HAVE_EDITLINE */
static void BreakpointHandler(ScriptFrame& frame, ScriptError *ex, const DebugInfo& di);
2014-11-23 12:35:13 +01:00
};
}
#endif /* CONSOLECOMMAND_H */