changeset 321:f23d71fa2b40

Irccdctl: bring back plugin-list
author David Demelier <markand@malikania.fr>
date Tue, 01 Nov 2016 10:01:07 +0100
parents 2ea95292fa77
children df5cc5e6b499
files irccdctl/cli-plugin-list.cpp irccdctl/cli-plugin-list.hpp
diffstat 2 files changed, 101 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-plugin-list.cpp	Tue Nov 01 10:01:07 2016 +0100
@@ -0,0 +1,48 @@
+/*
+ * cli-plugin-list.cpp -- implementation of irccdctl plugin-list
+ *
+ * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <iostream>
+
+#include "cli-plugin-list.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+PluginListCli::PluginListCli()
+    : Cli("plugin-list",
+          "list loaded plugins",
+          "plugin-list",
+          "Get the list of all loaded plugins.\n\n"
+          "Example:\n"
+          "\tirccdctl plugin-list")
+{
+}
+
+void PluginListCli::exec(Irccdctl &irccdctl, const std::vector<std::string> &)
+{
+    auto result = request(irccdctl);
+
+    for (const auto &value : result["list"])
+        if (value.is_string())
+            std::cout << value.get<std::string>() << std::endl;
+}
+
+} // !cli
+
+} // !irccd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-plugin-list.hpp	Tue Nov 01 10:01:07 2016 +0100
@@ -0,0 +1,53 @@
+/*
+ * cli-plugin-list.hpp -- implementation of irccdctl plugin-list
+ *
+ * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef IRCCDCTL_CLI_PLUGIN_LIST_HPP
+#define IRCCDCTL_CLI_PLUGIN_LIST_HPP
+
+/**
+ * \file cli-plugin-list.hpp
+ * \brief Implementation of irccdctl plugin-list.
+ */
+
+#include "cli.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+/**
+ * \brief Implementation of irccdctl plugin-list.
+ */
+class PluginListCli : public Cli {
+public:
+    /**
+     * Default constructor.
+     */
+    PluginListCli();
+
+    /**
+     * \copydoc Cli::exec
+     */
+    void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override;
+};
+
+} // !cli
+
+} // !irccd
+
+#endif // !IRCCDCTL_CLI_PLUGIN_LIST_HPP