summaryrefslogtreecommitdiffstats
path: root/lib/cli/consolecommand.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:32:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:32:39 +0000
commit56ae875861ab260b80a030f50c4aff9f9dc8fff0 (patch)
tree531412110fc901a5918c7f7442202804a83cada9 /lib/cli/consolecommand.hpp
parentInitial commit. (diff)
downloadicinga2-56ae875861ab260b80a030f50c4aff9f9dc8fff0.tar.xz
icinga2-56ae875861ab260b80a030f50c4aff9f9dc8fff0.zip
Adding upstream version 2.14.2.upstream/2.14.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--lib/cli/consolecommand.hpp61
1 files changed, 61 insertions, 0 deletions
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 <condition_variable>
+
+
+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<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 std::mutex m_Mutex;
+ mutable std::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);
+
+};
+
+}
+
+#endif /* CONSOLECOMMAND_H */