From 0915b3ef56dfac3113cce55a59a5765dc94976be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:34:54 +0200 Subject: Adding upstream version 2.13.6. Signed-off-by: Daniel Baumann --- lib/cli/consolecommand.hpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 lib/cli/consolecommand.hpp (limited to 'lib/cli/consolecommand.hpp') diff --git a/lib/cli/consolecommand.hpp b/lib/cli/consolecommand.hpp new file mode 100644 index 0000000..631ec21 --- /dev/null +++ b/lib/cli/consolecommand.hpp @@ -0,0 +1,61 @@ +/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ + +#ifndef CONSOLECOMMAND_H +#define CONSOLECOMMAND_H + +#include "cli/clicommand.hpp" +#include "base/exception.hpp" +#include "base/scriptframe.hpp" +#include "base/tlsstream.hpp" +#include "remote/url.hpp" +#include + + +namespace icinga +{ + +/** + * The "console" CLI command. + * + * @ingroup cli + */ +class ConsoleCommand final : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(ConsoleCommand); + + 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& 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 std::mutex m_Mutex; + mutable std::condition_variable m_CV; + + static Shared::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); + +}; + +} + +#endif /* CONSOLECOMMAND_H */ -- cgit v1.2.3