changeset 342:40abc6522cd7

Irccdctl: bring back server-disconnect
author David Demelier <markand@malikania.fr>
date Mon, 07 Nov 2016 13:14:57 +0100
parents 45065955ba2d
children 3d927ba4af75
files irccdctl/cli-plugin-config.hpp irccdctl/cli-server-disconnect.cpp irccdctl/cli-server-disconnect.hpp
diffstat 3 files changed, 153 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-plugin-config.hpp	Mon Nov 07 13:14:57 2016 +0100
@@ -0,0 +1,50 @@
+/*
+ * cli-plugin-config.hpp -- implementation of irccdctl plugin-info
+ *
+ * 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_CONFIG_HPP
+#define IRCCDCTL_CLI_PLUGIN_CONFIG_HPP
+
+/**
+ * \file cli-plugin-config.hpp
+ * \brief Implementation of irccdctl plugin-config
+ */
+
+#include "cli.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+class PluginConfigCli : public Cli {
+public:
+    /**
+     * Default constructor.
+     */
+    PluginConfigCli();
+
+    /**
+     * \copydoc Cli::exec
+     */
+    void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override;
+};
+
+} // !cli
+
+} // !irccd
+
+#endif // !IRCCDCTL_CLI_PLUGIN_CONFIG_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-server-disconnect.cpp	Mon Nov 07 13:14:57 2016 +0100
@@ -0,0 +1,50 @@
+/*
+ * cli-server-disconnect.cpp -- implementation of irccdctl server-disconnect
+ *
+ * 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 "cli-server-disconnect.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+ServerDisconnectCli::ServerDisconnectCli()
+    : Cli("server-disconnect",
+          "disconnect server",
+          "server-disconnect [server]",
+          "Disconnect from a server.\n\n"
+          "If server is not specified, irccd disconnects all servers.\n\n"
+          "Example:\n"
+          "\tirccdctl server-disconnect localhost")
+{
+}
+
+void ServerDisconnectCli::exec(Irccdctl &irccdctl, const std::vector<std::string> &args)
+{
+    auto object = nlohmann::json::object({
+        { "command", "server-disconnect" }
+    });
+
+    if (args.size() > 0)
+        object["server"] = args[0];
+
+    check(request(irccdctl, object));
+}
+
+} // !cli
+
+} // !irccd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-server-disconnect.hpp	Mon Nov 07 13:14:57 2016 +0100
@@ -0,0 +1,53 @@
+/*
+ * cli-server-disconnect.hpp -- implementation of irccdctl server-disconnect
+ *
+ * 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_SERVER_DISCONNECT_HPP
+#define IRCCDCTL_CLI_SERVER_DISCONNECT_HPP
+
+/**
+ * \file cli-server-disconnect.hpp
+ * \brief Implementation of irccdctl server-disconnect.
+ */
+
+#include "cli.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+/**
+ * \brief Implementation of irccdctl server-disconnect.
+ */
+class ServerDisconnectCli : public Cli {
+public:
+    /**
+     * Default constructor.
+     */
+    ServerDisconnectCli();
+
+    /**
+     * \copydoc Cli::exec
+     */
+    void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override;
+};
+
+} // !cli
+
+} // !irccd
+
+#endif // !IRCCDCTL_CLI_SERVER_DISCONNECT_HPP