changeset 331:4f1fb35ef30e

Irccdctl: bring back server-list
author David Demelier <markand@malikania.fr>
date Tue, 08 Nov 2016 22:39:55 +0100
parents a167353ab89e
children 9d09b8d882f3
files irccdctl/cli-server-list.cpp irccdctl/cli-server-list.hpp
diffstat 2 files changed, 103 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-server-list.cpp	Tue Nov 08 22:39:55 2016 +0100
@@ -0,0 +1,50 @@
+/*
+ * cli-server-list.cpp -- implementation of irccdctl server-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-server-list.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+ServerListCli::ServerListCli()
+    : Cli("server-list",
+          "get list of servers",
+          "server-list\n\n",
+          "Get the list of all connected servers.\n\n"
+          "Example:\n"
+          "\tirccdctl server-list")
+{
+}
+
+void ServerListCli::exec(Irccdctl &irccdctl, const std::vector<std::string> &)
+{
+    auto response = request(irccdctl);
+
+    check(response);
+
+    for (const auto &n : response["list"])
+        if (n.is_string())
+            std::cout << n.get<std::string>() << std::endl;
+}
+
+} // !cli
+
+} // !irccd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/irccdctl/cli-server-list.hpp	Tue Nov 08 22:39:55 2016 +0100
@@ -0,0 +1,53 @@
+/*
+ * cli-server-list.hpp -- implementation of irccdctl server-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_SERVER_LIST_HPP
+#define IRCCDCTL_CLI_SERVER_LIST_HPP
+
+/**
+ * \file cli-server-list.hpp
+ * \brief Implementation of irccdctl server-list.
+ */
+
+#include "cli.hpp"
+
+namespace irccd {
+
+namespace cli {
+
+/**
+ * \brief Implementation of irccdctl server-list.
+ */
+class ServerListCli : public Cli {
+public:
+    /**
+     * Default constructor.
+     */
+    ServerListCli();
+
+    /**
+     * \copydoc Cli::exec
+     */
+    void exec(Irccdctl &irccdctl, const std::vector<std::string> &args) override;
+};
+
+} // !command
+
+} // !irccd
+
+#endif // !IRCCDCTL_CLI_SERVER_LIST_HPP