# HG changeset patch # User David Demelier # Date 1479026754 -3600 # Node ID 006452e4a9973bacbae32d65304c670952c0ea98 # Parent 4665fffff6f266ca07cb71e293b7de6a4b0d7293 Irccdctl: unify cli commands diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/CMakeLists.txt --- a/irccdctl/CMakeLists.txt Sat Nov 12 22:58:48 2016 +0100 +++ b/irccdctl/CMakeLists.txt Sun Nov 13 09:45:54 2016 +0100 @@ -22,50 +22,6 @@ ${irccdctl_SOURCE_DIR}/CMakeLists.txt ${irccdctl_SOURCE_DIR}/cli.cpp ${irccdctl_SOURCE_DIR}/cli.hpp - ${irccdctl_SOURCE_DIR}/cli-plugin-config.cpp - ${irccdctl_SOURCE_DIR}/cli-plugin-config.hpp - ${irccdctl_SOURCE_DIR}/cli-plugin-info.cpp - ${irccdctl_SOURCE_DIR}/cli-plugin-info.hpp - ${irccdctl_SOURCE_DIR}/cli-plugin-list.cpp - ${irccdctl_SOURCE_DIR}/cli-plugin-list.hpp - ${irccdctl_SOURCE_DIR}/cli-plugin-load.cpp - ${irccdctl_SOURCE_DIR}/cli-plugin-load.hpp - ${irccdctl_SOURCE_DIR}/cli-plugin-reload.cpp - ${irccdctl_SOURCE_DIR}/cli-plugin-reload.hpp - ${irccdctl_SOURCE_DIR}/cli-plugin-unload.cpp - ${irccdctl_SOURCE_DIR}/cli-plugin-unload.hpp - ${irccdctl_SOURCE_DIR}/cli-server-cmode.cpp - ${irccdctl_SOURCE_DIR}/cli-server-cmode.hpp - ${irccdctl_SOURCE_DIR}/cli-server-cnotice.cpp - ${irccdctl_SOURCE_DIR}/cli-server-cnotice.hpp - ${irccdctl_SOURCE_DIR}/cli-server-connect.cpp - ${irccdctl_SOURCE_DIR}/cli-server-connect.hpp - ${irccdctl_SOURCE_DIR}/cli-server-disconnect.cpp - ${irccdctl_SOURCE_DIR}/cli-server-disconnect.hpp - ${irccdctl_SOURCE_DIR}/cli-server-info.cpp - ${irccdctl_SOURCE_DIR}/cli-server-info.hpp - ${irccdctl_SOURCE_DIR}/cli-server-invite.cpp - ${irccdctl_SOURCE_DIR}/cli-server-invite.hpp - ${irccdctl_SOURCE_DIR}/cli-server-join.cpp - ${irccdctl_SOURCE_DIR}/cli-server-join.hpp - ${irccdctl_SOURCE_DIR}/cli-server-kick.cpp - ${irccdctl_SOURCE_DIR}/cli-server-kick.hpp - ${irccdctl_SOURCE_DIR}/cli-server-list.cpp - ${irccdctl_SOURCE_DIR}/cli-server-list.hpp - ${irccdctl_SOURCE_DIR}/cli-server-me.cpp - ${irccdctl_SOURCE_DIR}/cli-server-me.hpp - ${irccdctl_SOURCE_DIR}/cli-server-message.cpp - ${irccdctl_SOURCE_DIR}/cli-server-message.hpp - ${irccdctl_SOURCE_DIR}/cli-server-mode.cpp - ${irccdctl_SOURCE_DIR}/cli-server-mode.hpp - ${irccdctl_SOURCE_DIR}/cli-server-nick.cpp - ${irccdctl_SOURCE_DIR}/cli-server-nick.hpp - ${irccdctl_SOURCE_DIR}/cli-server-notice.cpp - ${irccdctl_SOURCE_DIR}/cli-server-notice.hpp - ${irccdctl_SOURCE_DIR}/cli-server-part.cpp - ${irccdctl_SOURCE_DIR}/cli-server-part.hpp - ${irccdctl_SOURCE_DIR}/cli-server-reconnect.cpp - ${irccdctl_SOURCE_DIR}/cli-server-reconnect.hpp ${irccdctl_SOURCE_DIR}/main.cpp ) diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-config.cpp --- a/irccdctl/cli-plugin-config.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * cli-plugin-config.cpp -- implementation of irccdctl plugin-info - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 - -#include "cli-plugin-config.hpp" - -namespace irccd { - -namespace cli { - -void PluginConfigCli::set(Irccdctl &irccdctl, const std::vector &args) -{ - check(request(irccdctl, nlohmann::json::object({ - { "plugin", args[0] }, - { "variable", args[1] }, - { "value", args[2] } - }))); -} - -void PluginConfigCli::get(Irccdctl &irccdctl, const std::vector &args) -{ - auto result = request(irccdctl, nlohmann::json::object({ - { "plugin", args[0] }, - { "variable", args[1] } - })); - - check(result); - - if (result["variables"].is_object()) - std::cout << util::json::pretty(result["variables"][args[1]]) << std::endl; -} - -void PluginConfigCli::getall(Irccdctl &irccdctl, const std::vector &args) -{ - auto result = request(irccdctl, nlohmann::json::object({{ "plugin", args[0] }})); - - check(result); - - auto variables = result["variables"]; - - for (auto v = variables.begin(); v != variables.end(); ++v) - std::cout << std::setw(16) << std::left << v.key() << " : " << util::json::pretty(v.value()) << std::endl; -} - -PluginConfigCli::PluginConfigCli() - : Cli("plugin-config", - "configure a plugin", - "plugin-config plugin [variable] [value]", - "Get or set plugin configuration.\n\n" - "Examples:\n" - "\tirccdctl plugin-config ask") -{ -} - -void PluginConfigCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - switch (args.size()) { - case 3: - set(irccdctl, args); - break; - case 2: - get(irccdctl, args); - break; - case 1: - getall(irccdctl, args); - break; - default: - throw std::invalid_argument("plugin-config requires at least 1 argument"); - } -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-config.hpp --- a/irccdctl/cli-plugin-config.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * cli-plugin-config.hpp -- implementation of irccdctl plugin-info - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 { -private: - void set(Irccdctl &, const std::vector &); - void get(Irccdctl &, const std::vector &); - void getall(Irccdctl &, const std::vector &); - -public: - /** - * Default constructor. - */ - PluginConfigCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_PLUGIN_CONFIG_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-info.cpp --- a/irccdctl/cli-plugin-info.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * cli-plugin-info.cpp -- implementation of irccdctl plugin-info - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 - -#include - -#include "cli-plugin-info.hpp" - -namespace irccd { - -namespace cli { - -PluginInfoCli::PluginInfoCli() - : Cli("plugin-info", - "get plugin information", - "plugin-info plugin", - "Get plugin information\n\n" - "Example:\n" - "\tirccdctl plugin-info ask" - ) -{ -} - -void PluginInfoCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 1) - throw std::invalid_argument("plugin-info requires 1 argument"); - - auto result = request(irccdctl, {{ "plugin", args[0] }}); - - std::cout << std::boolalpha; - std::cout << "Author : " << util::json::getString(result, "author") << std::endl; - std::cout << "License : " << util::json::getString(result, "license") << std::endl; - std::cout << "Summary : " << util::json::getString(result, "summary") << std::endl; - std::cout << "Version : " << util::json::getString(result, "version") << std::endl; -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-info.hpp --- a/irccdctl/cli-plugin-info.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-plugin-info.hpp -- implementation of irccdctl plugin-info - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_INFO_HPP -#define IRCCDCTL_CLI_PLUGIN_INFO_HPP - -/** - * \file cli-plugin-info.hpp - * \brief Implementation of irccdctl plugin-info. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl plugin-info. - */ -class PluginInfoCli : public Cli { -public: - /** - * Default constructor. - */ - PluginInfoCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !commands - -} // !irccd - -#endif // !IRCCDCTL_CLI_PLUGIN_INFO_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-list.cpp --- a/irccdctl/cli-plugin-list.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * cli-plugin-list.cpp -- implementation of irccdctl plugin-list - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 - -#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 &) -{ - auto result = request(irccdctl); - - for (const auto &value : result["list"]) - if (value.is_string()) - std::cout << value.get() << std::endl; -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-list.hpp --- a/irccdctl/cli-plugin-list.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-plugin-list.hpp -- implementation of irccdctl plugin-list - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_PLUGIN_LIST_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-load.cpp --- a/irccdctl/cli-plugin-load.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * cli-plugin-load.cpp -- implementation of irccdctl plugin-load - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-plugin-load.hpp" - -namespace irccd { - -namespace cli { - -PluginLoadCli::PluginLoadCli() - : Cli("plugin-load", - "load a plugin", - "plugin-load logger", - "Load a plugin into the irccd instance.\n\n" - "Example:\n" - "\tirccdctl plugin-load logger") -{ -} - -void PluginLoadCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 1) - throw std::invalid_argument("plugin-load requires 1 argument"); - - check(request(irccdctl, {{"plugin", args[0]}})); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-load.hpp --- a/irccdctl/cli-plugin-load.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-plugin-load.hpp -- implementation of irccdctl plugin-load - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_LOAD_HPP -#define IRCCDCTL_CLI_PLUGIN_LOAD_HPP - -/** - * \file cli-plugin-load.hpp - * \brief Implementation of irccdctl plugin-load. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl plugin-load. - */ -class PluginLoadCli : public Cli { -public: - /** - * Default constructor. - */ - PluginLoadCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_PLUGIN_LOAD_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-reload.cpp --- a/irccdctl/cli-plugin-reload.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * command-plugin-reload.cpp -- implementation of irccdctl plugin-reload - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-plugin-reload.hpp" - -namespace irccd { - -namespace cli { - -PluginReloadCli::PluginReloadCli() - : Cli("plugin-reload", - "reload a plugin", - "plugin-reload plugin", - "Call the onReload event on the specified plugin.") -{ -} - -void PluginReloadCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 1) - throw std::invalid_argument("plugin-reload requires 1 argument"); - - check(request(irccdctl, {{ "plugin", args[0] }})); -} - -} // !command - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-reload.hpp --- a/irccdctl/cli-plugin-reload.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * cli-plugin-reload.hpp -- implementation of irccdctl plugin-reload - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_RELOAD_HPP -#define IRCCDCTL_CLI_PLUGIN_RELOAD_HPP - -/** - * \file cli-plugin-reload.hpp - * \brief Implementation of irccdctl plugin-reload. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl plugin-reload. - */ -class PluginReloadCli : public Cli { -public: - PluginReloadCli(); - - /** - * \copydoc Command::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_PLUGIN_RELOAD_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-unload.cpp --- a/irccdctl/cli-plugin-unload.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * cli-plugin-unload.cpp -- implementation of irccdctl plugin-unload - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-plugin-unload.hpp" - -namespace irccd { - -namespace cli { - -PluginUnloadCli::PluginUnloadCli() - : Cli("plugin-unload", - "unload a plugin", - "plugin-unload plugin", - "Unload a loaded plugin from the irccd instance.\n\n" - "Example:\n" - "tirccdctl plugin-unload logger") -{ -} - -void PluginUnloadCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 1) - throw std::invalid_argument("plugin-unload requires 1 argument"); - - check(request(irccdctl, {{ "plugin", args[0] }})); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-plugin-unload.hpp --- a/irccdctl/cli-plugin-unload.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * cli-plugin-unload.hpp -- implementation of irccdctl plugin-unload - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_UNLOAD_HPP -#define IRCCDCTL_CLI_PLUGIN_UNLOAD_HPP - -/** - * \file cli-plugin-unload.hpp - * \brief Implementation of irccdctl plugin-unload. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl plugin-unload. - */ -class PluginUnloadCli : public Cli { -public: - PluginUnloadCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_PLUGIN_UNLOAD_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-cmode.cpp --- a/irccdctl/cli-server-cmode.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * command-server-cmode.cpp -- implementation of irccdctl server-mode - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-cmode.hpp" - -namespace irccd { - -namespace cli { - -ServerChannelMode::ServerChannelMode() - : Cli("server-cmode", - "change channel mode", - "server-cmode server channel mode", - "Change the mode of the specified channel.\n\n" - "Example:\n" - "\tirccdctl server-cmode freenode #staff +t") -{ -} - -void ServerChannelMode::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 3) - throw std::invalid_argument("server-cmode requires 3 arguments"); - - check(request(irccdctl, { - { "command", "server-cmode" }, - { "server", args[0] }, - { "channel", args[1] }, - { "mode", args[2] } - })); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-cmode.hpp --- a/irccdctl/cli-server-cmode.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-cmode.hpp -- implementation of irccdctl server-cmode - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_CMODE_HPP -#define IRCCDCTL_CLI_SERVER_CMODE_HPP - -/** - * \file cli-server-cmode.hpp - * \brief Implementation of irccdctl server-cmode. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-cmode. - */ -class ServerChannelMode : public Cli { -public: - /** - * Default constructor. - */ - ServerChannelMode(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_CMODE_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-cnotice.cpp --- a/irccdctl/cli-server-cnotice.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * cli-server-cnotice.cpp -- implementation of irccdctl server-cnotice - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-cnotice.hpp" - -namespace irccd { - -namespace cli { - -ServerChannelNoticeCli::ServerChannelNoticeCli() - : Cli("server-cnotice", - "send a channel notice", - "server-cnotice server channel message", - "Send a message notice on a channel.\n\n" - "Example:\n" - "\tirccdctl server-cnotice freenode #staff \"Don't flood!\"") -{ -} - -void ServerChannelNoticeCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 3) - throw std::invalid_argument("server-cnotice requires 3 arguments"); - - check(request(irccdctl, { - { "command", "server-cnotice" }, - { "server", args[0] }, - { "channel", args[1] }, - { "message", args[2] } - })); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-cnotice.hpp --- a/irccdctl/cli-server-cnotice.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-cnotice.hpp -- implementation of irccdctl server-cnotice - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_CNOTICE_HPP -#define IRCCDCTL_CLI_SERVER_CNOTICE_HPP - -/** - * \file cli-server-cnotice.hpp - * \brief Implementation of irccdctl server-cnotice. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-cnotice. - */ -class ServerChannelNoticeCli : public Cli { -public: - /** - * Default constructor. - */ - ServerChannelNoticeCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_CNOTICE_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-connect.cpp --- a/irccdctl/cli-server-connect.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -/* - * command-server-connect.cpp -- implementation of irccdctl server-connect - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 -#include - -#include "cli-server-connect.hpp" - -namespace irccd { - -namespace cli { - -namespace { - -option::Result parse(std::vector &args) -{ - option::Options options{ - { "-c", true }, - { "--command", true }, - { "-n", true }, - { "--nickname", true }, - { "-r", true }, - { "--realname", true }, - { "-S", false }, - { "--ssl-verify", false }, - { "-s", false }, - { "--ssl", false }, - { "-u", true }, - { "--username", true } - }; - - return option::read(args, options); -} - -} // !namespace - -#if 0 -void ServerConnect::usage(Irccdctl &) const -{ - -} -#endif - -ServerConnectCli::ServerConnectCli() - : Cli("server-connect", - "add a server", - "server-connect [options] id host [port]", - "Connect to a server.\n\n" - "Available options:\n" - " -c, --command\t\tspecify the command char\n" - " -n, --nickname\tspecify a nickname\n" - " -r, --realname\tspecify a real name\n" - " -S, --ssl-verify\tverify SSL\n" - " -s, --ssl\t\tconnect using SSL\n" - " -u, --username\tspecify a user name\n\n" - "Example:\n" - "\tirccdctl server-connect -n jean example irc.example.org\n" - "\tirccdctl server-connect --ssl example irc.example.org 6697") -{ -} - -void ServerConnectCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - std::vector copy(args); - - option::Result result = parse(copy); - option::Result::const_iterator it; - - if (copy.size() < 2) - throw std::invalid_argument("server-connect requires at least 2 arguments"); - - auto object = nlohmann::json::object({ - { "name", copy[0] }, - { "host", copy[1] } - }); - - if (copy.size() == 3) { - if (!util::isNumber(copy[2])) - throw std::invalid_argument("invalid port number"); - - object["port"] = std::stoi(copy[2]); - } - - if (result.count("-S") > 0 || result.count("--ssl-verify") > 0) - object["sslVerify"] = true; - if (result.count("-s") > 0 || result.count("--ssl") > 0) - object["ssl"] = true; - if ((it = result.find("-n")) != result.end() || (it = result.find("--nickname")) != result.end()) - object["nickname"] = it->second; - if ((it = result.find("-r")) != result.end() || (it = result.find("--realname")) != result.end()) - object["realname"] = it->second; - if ((it = result.find("-u")) != result.end() || (it = result.find("--username")) != result.end()) - object["username"] = it->second; - - check(request(irccdctl, object)); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-connect.hpp --- a/irccdctl/cli-server-connect.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * command-server-connect.h -- implementation of irccdctl server-connect - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_CONNECT_HPP -#define IRCCDCTL_CLI_SERVER_CONNECT_HPP - -/** - * \file cli-server-connect.hpp - * \brief Implementation of irccdctl server-connect. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-connect. - */ -class ServerConnectCli : public Cli { -public: - /** - * Default constructor. - */ - ServerConnectCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_CONNECT_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-disconnect.cpp --- a/irccdctl/cli-server-disconnect.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * cli-server-disconnect.cpp -- implementation of irccdctl server-disconnect - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 &args) -{ - auto object = nlohmann::json::object({ - { "command", "server-disconnect" } - }); - - if (args.size() > 0) - object["server"] = args[0]; - - check(request(irccdctl, object)); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-disconnect.hpp --- a/irccdctl/cli-server-disconnect.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-disconnect.hpp -- implementation of irccdctl server-disconnect - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_DISCONNECT_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-info.cpp --- a/irccdctl/cli-server-info.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * cli-server-info.cpp -- implementation of irccdctl server-info - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 - -#include "cli-server-info.hpp" -#include "util.hpp" - -namespace irccd { - -namespace cli { - -ServerInfoCli::ServerInfoCli() - : Cli("server-info", - "get server information", - "server-info server", - "Get information about a server.\n\n" - "Example:\n" - "\tirccdctl server-info freenode") -{ -} - -void ServerInfoCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 1) - throw std::invalid_argument("server-info requires 1 argument"); - - auto result = request(irccdctl, { - { "command", "server-info" }, - { "server", args[0] } - }); - - check(result); - - std::cout << std::boolalpha; - std::cout << "Name : " << util::json::pretty(result["name"]) << std::endl; - std::cout << "Host : " << util::json::pretty(result["host"]) << std::endl; - std::cout << "Port : " << util::json::pretty(result["port"]) << std::endl; - std::cout << "Ipv6 : " << util::json::pretty(result["ipv6"]) << std::endl; - std::cout << "SSL : " << util::json::pretty(result["ssl"]) << std::endl; - std::cout << "SSL verified : " << util::json::pretty(result["sslVerify"]) << std::endl; - std::cout << "Channels : "; - - for (const auto &v : result["channels"]) - if (v.is_string()) - std::cout << v.get() << " "; - - std::cout << std::endl; - - std::cout << "Nickname : " << util::json::pretty(result["nickname"]) << std::endl; - std::cout << "User name : " << util::json::pretty(result["username"]) << std::endl; - std::cout << "Real name : " << util::json::pretty(result["realname"]) << std::endl; -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-info.hpp --- a/irccdctl/cli-server-info.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-info.hpp -- implementation of irccdctl server-info - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_SERVER_INFO_HPP -#define IRCCDCTL_SERVER_INFO_HPP - -/** - * \file cli-server-info.hpp - * \brief Implementation of irccdctl server-info. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-info. - */ -class ServerInfoCli : public Cli { -public: - /** - * Default constructor. - */ - ServerInfoCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_SERVER_INFO_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-invite.cpp --- a/irccdctl/cli-server-invite.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * command-server-invite.cpp -- implementation of irccdctl server-invite - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-invite.hpp" - -namespace irccd { - -namespace cli { - -ServerInviteCli::ServerInviteCli() - : Cli("server-invite", - "invite someone", - "server-invite server nickname channel", - "Invite the specified target on the channel.\n\n" - "Example:\n" - "\tirccdctl server-invite freenode xorg62 #staff") -{ -} - -void ServerInviteCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 3) - throw std::invalid_argument("server-invite requires 3 arguments"); - - check(request(irccdctl, { - { "command", "server-invite" }, - { "server", args[0] }, - { "target", args[1] }, - { "channel", args[2] } - })); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-invite.hpp --- a/irccdctl/cli-server-invite.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-invite.hpp -- implementation of irccdctl server-invite - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_INVITE_HPP -#define IRCCDCTL_CLI_SERVER_INVITE_HPP - -/** - * \file cli-server-invite.hpp - * \brief Implementation of irccdctl server-invite. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-invite. - */ -class ServerInviteCli : public Cli { -public: - /** - * Default constructor. - */ - ServerInviteCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_INVITE_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-join.cpp --- a/irccdctl/cli-server-join.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * cli-server-join.cpp -- implementation of irccdctl server-join - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-join.hpp" - -namespace irccd { - -namespace cli { - -ServerJoinCli::ServerJoinCli() - : Cli("server-join", - "join a channel", - "server-join server channel [password]", - "Join the specified channel, the password is optional.\n\n" - "Example:\n" - "\tirccdctl server-join freenode #test\n" - "\tirccdctl server-join freenode #private-club secret") -{ -} - -void ServerJoinCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 2) - throw std::invalid_argument("server-join requires at least 2 arguments"); - - auto object = nlohmann::json::object({ - { "server", args[0] }, - { "channel", args[1] } - }); - - if (args.size() == 3) - object["password"] = args[2]; - - check(request(irccdctl, object)); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-join.hpp --- a/irccdctl/cli-server-join.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-join.hpp -- implementation of irccdctl server-join - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_JOIN_HPP -#define IRCCDCTL_CLI_SERVER_JOIN_HPP - -/** - * \file cli-server-join.hpp - * \brief Implementation of irccdctl server-join. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-join. - */ -class ServerJoinCli : public Cli { -public: - /** - * Default constructor. - */ - ServerJoinCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !command - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_JOIN_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-kick.cpp --- a/irccdctl/cli-server-kick.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * cli-server-kick.cpp -- implementation of irccdctl server-kick - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-kick.hpp" - -namespace irccd { - -namespace cli { - -ServerKickCli::ServerKickCli() - : Cli("server-kick", - "kick someone from a channel", - "server-kick server target channel [reason]", - "Kick the specified target from the channel, the reason is optional.\n\n" - "Example:\n" - "\tirccdctl server-kick freenode jean #staff \"Stop flooding\"") -{ -} - -void ServerKickCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 3) - throw std::invalid_argument("server-kick requires at least 3 arguments "); - - auto object = nlohmann::json::object({ - { "server", args[0] }, - { "target", args[1] }, - { "channel", args[2] } - }); - - if (args.size() == 4) - object["reason"] = args[3]; - - check(request(irccdctl, object)); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-kick.hpp --- a/irccdctl/cli-server-kick.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-kick.hpp -- implementation of irccdctl server-kick - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_SERVER_KICK_HPP -#define IRCCDCTL_SERVER_KICK_HPP - -/** - * \file cli-server-kick.hpp - * \brief Implementation of irccdctl server-kick. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-kick. - */ -class ServerKickCli : public Cli { -public: - /** - * Default constructor. - */ - ServerKickCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_SERVER_KICK_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-list.cpp --- a/irccdctl/cli-server-list.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * cli-server-list.cpp -- implementation of irccdctl server-list - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 - -#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 &) -{ - auto response = request(irccdctl); - - check(response); - - for (const auto &n : response["list"]) - if (n.is_string()) - std::cout << n.get() << std::endl; -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-list.hpp --- a/irccdctl/cli-server-list.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-list.hpp -- implementation of irccdctl server-list - * - * Copyright (c) 2013-2016 David Demelier - * - * 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 &args) override; -}; - -} // !command - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_LIST_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-me.cpp --- a/irccdctl/cli-server-me.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * cli-server-me.cpp -- implementation of irccdctl server-me - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-me.hpp" - -namespace irccd { - -namespace cli { - -ServerMeCli::ServerMeCli() - : Cli("server-me", - "send an action emote", - "server-me server target message", - "Send an action emote.\n\n" - "Example:\n" - "\tirccdctl server-me freenode #staff \"going back soon\"") -{ -} - -void ServerMeCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 3) - throw std::runtime_error("server-me requires 3 arguments"); - - check(request(irccdctl, { - { "server", args[0] }, - { "target", args[1] }, - { "message", args[2] } - })); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-me.hpp --- a/irccdctl/cli-server-me.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-me.hpp -- implementation of irccdctl server-me - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_ME_HPP -#define IRCCDCTL_CLI_SERVER_ME_HPP - -/** - * \file cli-server-me.hpp - * \brief Implementation of irccdctl server-me. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-me. - */ -class ServerMeCli : public Cli { -public: - /** - * Default constructor. - */ - ServerMeCli(); - - /** - * \copydoc Command::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !_IRCCDCTL_COMMAND_SERVER_ME_H_ diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-message.cpp --- a/irccdctl/cli-server-message.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * cli-server-message.cpp -- implementation of irccdctl server-message - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-message.hpp" - -namespace irccd { - -namespace cli { - -ServerMessageCli::ServerMessageCli() - : Cli("server-message", - "send a message", - "server-message server target message", - "Send a message to the specified target or channel.\n\n" - "Example:\n" - "\tirccdctl server-message freenode #staff \"Hello from irccd\"") -{ -} - -void ServerMessageCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 3) - throw std::invalid_argument("server-message requires 3 arguments"); - - check(request(irccdctl, { - { "server", args[0] }, - { "target", args[1] }, - { "message", args[2] } - })); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-message.hpp --- a/irccdctl/cli-server-message.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-message.hpp -- implementation of irccdctl server-message - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_MESSAGE_HPP -#define IRCCDCTL_CLI_SERVER_MESSAGE_HPP - -/** - * \file cli-server-message.hpp - * \brief Implementation of irccdctl server-message. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-message. - */ -class ServerMessageCli : public Cli { -public: - /** - * Default constructor. - */ - ServerMessageCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_MESSAGE_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-mode.cpp --- a/irccdctl/cli-server-mode.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * cli-server-mode.cpp -- implementation of irccdctl server-mode - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-mode.hpp" - -namespace irccd { - -namespace cli { - -ServerModeCli::ServerModeCli() - : Cli("server-mode", - "the the user mode", - "server-mode server mode", - "Set the irccd's user mode.\n\n" - "Example:\n" - "\tirccdctl server-mode +i") -{ -} - -void ServerModeCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 2) - throw std::invalid_argument("server-mode requires 2 arguments"); - - check(request(irccdctl, { - { "server", args[0] }, - { "mode", args[1] } - })); -} - -} // !command - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-mode.hpp --- a/irccdctl/cli-server-mode.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-mode.hpp -- implementation of irccdctl server-mode - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_MODE_HPP -#define IRCCDCTL_CLI_SERVER_MODE_HPP - -/** - * \file cli-server-mode.hpp - * \brief Implementation of irccdctl server-mode. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-mode. - */ -class ServerModeCli : public Cli { -public: - /** - * Default constructor. - */ - ServerModeCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_MODE_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-nick.cpp --- a/irccdctl/cli-server-nick.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * cli-server-nick.cpp -- implementation of irccdctl server-nick - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-nick.hpp" - -namespace irccd { - -namespace cli { - -ServerNickCli::ServerNickCli() - : Cli("server-nick", - "change your nickname", - "server-nick server nickname", - "Change irccd's nickname.\n\n" - "Example:\n" - "\tirccdctl server-nick freenode david") -{ -} - -void ServerNickCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 2) - throw std::invalid_argument("server-nick requires 2 arguments"); - - check(request(irccdctl, { - { "server", args[0] }, - { "nickname", args[1] } - })); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-nick.hpp --- a/irccdctl/cli-server-nick.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-nick.hpp -- implementation of irccdctl server-nick - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_NICK_HPP -#define IRCCDCTL_CLI_SERVER_NICK_HPP - -/** - * \file cli-server-nick.hpp - * \brief Implementation of irccdctl server-nick. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-nick. - */ -class ServerNickCli : public Cli { -public: - /** - * Default constructor. - */ - ServerNickCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_NICK_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-notice.cpp --- a/irccdctl/cli-server-notice.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * cli-server-notice.cpp -- implementation of irccdctl server-notice - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-notice.hpp" - -namespace irccd { - -namespace cli { - -ServerNoticeCli::ServerNoticeCli() - : Cli("server-notice", - "send a private notice", - "server-notice server target message", - "Send a private notice to the specified target.\n\n" - "Example:\n" - "\tirccdctl server-notice freenode jean \"I know you are here.\"") -{ -} - -void ServerNoticeCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 3) - throw std::invalid_argument("server-notice requires 3 arguments"); - - check(request(irccdctl, { - { "server", args[0] }, - { "target", args[1] }, - { "message", args[2] } - })); -} - -} // !cli - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-notice.hpp --- a/irccdctl/cli-server-notice.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-notice.hpp -- implementation of irccdctl server-notice - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_NOTICE_HPP -#define IRCCDCTL_CLI_SERVER_NOTICE_HPP - -/** - * \file cli-server-cnotice.hpp - * \brief Implementation of irccdctl server-notice. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-notice. - */ -class ServerNoticeCli : public Cli { -public: - /** - * Default constructor. - */ - ServerNoticeCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_NOTICE_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-part.cpp --- a/irccdctl/cli-server-part.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* - * cli-server-part.cpp -- implementation of irccdctl server-part - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-part.hpp" - -namespace irccd { - -namespace cli { - -ServerPartCli::ServerPartCli() - : Cli("server-part", - "leave a channel", - "server-part server channel [reason]", - "Leave the specified channel, the reason is optional.\n\n" - "Not all IRC servers support giving a reason to leave a channel, do not " - "specify it if this is a concern.\n\n" - "Example:\n" - "\tirccdctl server-part freenode #staff" - "\tirccdctl server-part freenode #botwar \"too noisy\"") -{ -} - -void ServerPartCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - if (args.size() < 2) - throw std::invalid_argument("server-part requires at least 2 arguments"); - - auto object = nlohmann::json::object({ - { "server", args[0] }, - { "channel", args[1] } - }); - - if (args.size() >= 3) - object["reason"] = args[2]; - - check(request(irccdctl, object)); -} - -} // !command - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-part.hpp --- a/irccdctl/cli-server-part.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-part.hpp -- implementation of irccdctl server-part - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_PART_HPP -#define IRCCDCTL_CLI_SERVER_PART_HPP - -/** - * \file cli-server-part.hpp - * \brief Implementation of irccdctl server-part. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-part. - */ -class ServerPartCli : public Cli { -public: - /** - * Default constructor. - */ - ServerPartCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !cli - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_PART_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-reconnect.cpp --- a/irccdctl/cli-server-reconnect.cpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - * command-server-reconnect.cpp -- implementation of irccdctl server-reconnect - * - * Copyright (c) 2013-2016 David Demelier - * - * 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-reconnect.hpp" - -namespace irccd { - -namespace cli { - -#if 0 - -void ServerReconnect::usage(Irccdctl &) const -{ -"usage: " << sys::programName() << " server-reconnect [server]\n\n"; - -} - -#endif - -ServerReconnectCli::ServerReconnectCli() - : Cli("server-reconnect", - "force reconnection of a server", - "server-reconnect [server]", - "Force reconnection of one or all servers.\n\n" - "If server is not specified, all servers will try to reconnect.\n\n" - "Example:\n" - "\tirccdctl server-reconnect\n" - "\tirccdctl server-reconnect wanadoo") -{ -} - -void ServerReconnectCli::exec(Irccdctl &irccdctl, const std::vector &args) -{ - auto object = nlohmann::json::object({ - { "command", "server-reconnect" } - }); - - if (args.size() >= 1) - object["server"] = args[0]; - - check(request(irccdctl, object)); -} - -} // !command - -} // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli-server-reconnect.hpp --- a/irccdctl/cli-server-reconnect.hpp Sat Nov 12 22:58:48 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * cli-server-reconnect.hpp -- implementation of irccdctl server-reconnect - * - * Copyright (c) 2013-2016 David Demelier - * - * 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_RECONNECT_HPP -#define IRCCDCTL_CLI_SERVER_RECONNECT_HPP - -/** - * \file cli-server-reconnect.hpp - * \brief Implementation of irccdctl server-reconnect. - */ - -#include "cli.hpp" - -namespace irccd { - -namespace cli { - -/** - * \brief Implementation of irccdctl server-reconnect. - */ -class ServerReconnectCli : public Cli { -public: - /** - * Default constructor. - */ - ServerReconnectCli(); - - /** - * \copydoc Cli::exec - */ - void exec(Irccdctl &irccdctl, const std::vector &args) override; -}; - -} // !command - -} // !irccd - -#endif // !IRCCDCTL_CLI_SERVER_RECONNECT_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli.cpp --- a/irccdctl/cli.cpp Sat Nov 12 22:58:48 2016 +0100 +++ b/irccdctl/cli.cpp Sun Nov 13 09:45:54 2016 +0100 @@ -16,15 +16,23 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include #include "cli.hpp" +#include "elapsed-timer.hpp" #include "irccdctl.hpp" +#include "options.hpp" #include "util.hpp" -#include "elapsed-timer.hpp" namespace irccd { +/* + * Cli. + * ------------------------------------------------------------------ + */ + void Cli::check(const nlohmann::json &response) { if (!util::json::getBool(response, "status", false)) { @@ -80,4 +88,723 @@ check(request(irccdctl, args)); } +namespace cli { + +/* + * PluginConfigCli. + * ------------------------------------------------------------------ + */ + +void PluginConfigCli::set(Irccdctl &irccdctl, const std::vector &args) +{ + check(request(irccdctl, nlohmann::json::object({ + { "plugin", args[0] }, + { "variable", args[1] }, + { "value", args[2] } + }))); +} + +void PluginConfigCli::get(Irccdctl &irccdctl, const std::vector &args) +{ + auto result = request(irccdctl, nlohmann::json::object({ + { "plugin", args[0] }, + { "variable", args[1] } + })); + + check(result); + + if (result["variables"].is_object()) + std::cout << util::json::pretty(result["variables"][args[1]]) << std::endl; +} + +void PluginConfigCli::getall(Irccdctl &irccdctl, const std::vector &args) +{ + auto result = request(irccdctl, nlohmann::json::object({{ "plugin", args[0] }})); + + check(result); + + auto variables = result["variables"]; + + for (auto v = variables.begin(); v != variables.end(); ++v) + std::cout << std::setw(16) << std::left << v.key() << " : " << util::json::pretty(v.value()) << std::endl; +} + +PluginConfigCli::PluginConfigCli() + : Cli("plugin-config", + "configure a plugin", + "plugin-config plugin [variable] [value]", + "Get or set plugin configuration.\n\n" + "Examples:\n" + "\tirccdctl plugin-config ask") +{ +} + +void PluginConfigCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + switch (args.size()) { + case 3: + set(irccdctl, args); + break; + case 2: + get(irccdctl, args); + break; + case 1: + getall(irccdctl, args); + break; + default: + throw std::invalid_argument("plugin-config requires at least 1 argument"); + } +} + +/* + * PluginInfoCli. + * ------------------------------------------------------------------ + */ + +PluginInfoCli::PluginInfoCli() + : Cli("plugin-info", + "get plugin information", + "plugin-info plugin", + "Get plugin information\n\n" + "Example:\n" + "\tirccdctl plugin-info ask" + ) +{ +} + +void PluginInfoCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 1) + throw std::invalid_argument("plugin-info requires 1 argument"); + + auto result = request(irccdctl, {{ "plugin", args[0] }}); + + std::cout << std::boolalpha; + std::cout << "Author : " << util::json::getString(result, "author") << std::endl; + std::cout << "License : " << util::json::getString(result, "license") << std::endl; + std::cout << "Summary : " << util::json::getString(result, "summary") << std::endl; + std::cout << "Version : " << util::json::getString(result, "version") << std::endl; +} + +/* + * PluginListCli. + * ------------------------------------------------------------------ + */ + +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 &) +{ + auto result = request(irccdctl); + + for (const auto &value : result["list"]) + if (value.is_string()) + std::cout << value.get() << std::endl; +} + +/* + * PluginLoadCli. + * ------------------------------------------------------------------ + */ + +PluginLoadCli::PluginLoadCli() + : Cli("plugin-load", + "load a plugin", + "plugin-load logger", + "Load a plugin into the irccd instance.\n\n" + "Example:\n" + "\tirccdctl plugin-load logger") +{ +} + +void PluginLoadCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 1) + throw std::invalid_argument("plugin-load requires 1 argument"); + + check(request(irccdctl, {{"plugin", args[0]}})); +} + +/* + * PluginReloadCli. + * ------------------------------------------------------------------ + */ + +PluginReloadCli::PluginReloadCli() + : Cli("plugin-reload", + "reload a plugin", + "plugin-reload plugin", + "Call the onReload event on the specified plugin.") +{ +} + +void PluginReloadCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 1) + throw std::invalid_argument("plugin-reload requires 1 argument"); + + check(request(irccdctl, {{ "plugin", args[0] }})); +} + +/* + * PluginUnloadCli. + * ------------------------------------------------------------------ + */ + +PluginUnloadCli::PluginUnloadCli() + : Cli("plugin-unload", + "unload a plugin", + "plugin-unload plugin", + "Unload a loaded plugin from the irccd instance.\n\n" + "Example:\n" + "tirccdctl plugin-unload logger") +{ +} + +void PluginUnloadCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 1) + throw std::invalid_argument("plugin-unload requires 1 argument"); + + check(request(irccdctl, {{ "plugin", args[0] }})); +} + +/* + * ServerChannelCli. + * ------------------------------------------------------------------ + */ + +ServerChannelMode::ServerChannelMode() + : Cli("server-cmode", + "change channel mode", + "server-cmode server channel mode", + "Change the mode of the specified channel.\n\n" + "Example:\n" + "\tirccdctl server-cmode freenode #staff +t") +{ +} + +void ServerChannelMode::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 3) + throw std::invalid_argument("server-cmode requires 3 arguments"); + + check(request(irccdctl, { + { "command", "server-cmode" }, + { "server", args[0] }, + { "channel", args[1] }, + { "mode", args[2] } + })); +} + +/* + * ServerChannelNoticeCli. + * ------------------------------------------------------------------ + */ + +ServerChannelNoticeCli::ServerChannelNoticeCli() + : Cli("server-cnotice", + "send a channel notice", + "server-cnotice server channel message", + "Send a message notice on a channel.\n\n" + "Example:\n" + "\tirccdctl server-cnotice freenode #staff \"Don't flood!\"") +{ +} + +void ServerChannelNoticeCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 3) + throw std::invalid_argument("server-cnotice requires 3 arguments"); + + check(request(irccdctl, { + { "command", "server-cnotice" }, + { "server", args[0] }, + { "channel", args[1] }, + { "message", args[2] } + })); +} + +/* + * ServerConnectCli. + * ------------------------------------------------------------------ + */ + +namespace { + +option::Result parse(std::vector &args) +{ + option::Options options{ + { "-c", true }, + { "--command", true }, + { "-n", true }, + { "--nickname", true }, + { "-r", true }, + { "--realname", true }, + { "-S", false }, + { "--ssl-verify", false }, + { "-s", false }, + { "--ssl", false }, + { "-u", true }, + { "--username", true } + }; + + return option::read(args, options); +} + +} // !namespace + +ServerConnectCli::ServerConnectCli() + : Cli("server-connect", + "add a server", + "server-connect [options] id host [port]", + "Connect to a server.\n\n" + "Available options:\n" + " -c, --command\t\tspecify the command char\n" + " -n, --nickname\tspecify a nickname\n" + " -r, --realname\tspecify a real name\n" + " -S, --ssl-verify\tverify SSL\n" + " -s, --ssl\t\tconnect using SSL\n" + " -u, --username\tspecify a user name\n\n" + "Example:\n" + "\tirccdctl server-connect -n jean example irc.example.org\n" + "\tirccdctl server-connect --ssl example irc.example.org 6697") +{ +} + +void ServerConnectCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + std::vector copy(args); + + option::Result result = parse(copy); + option::Result::const_iterator it; + + if (copy.size() < 2) + throw std::invalid_argument("server-connect requires at least 2 arguments"); + + auto object = nlohmann::json::object({ + { "name", copy[0] }, + { "host", copy[1] } + }); + + if (copy.size() == 3) { + if (!util::isNumber(copy[2])) + throw std::invalid_argument("invalid port number"); + + object["port"] = std::stoi(copy[2]); + } + + if (result.count("-S") > 0 || result.count("--ssl-verify") > 0) + object["sslVerify"] = true; + if (result.count("-s") > 0 || result.count("--ssl") > 0) + object["ssl"] = true; + if ((it = result.find("-n")) != result.end() || (it = result.find("--nickname")) != result.end()) + object["nickname"] = it->second; + if ((it = result.find("-r")) != result.end() || (it = result.find("--realname")) != result.end()) + object["realname"] = it->second; + if ((it = result.find("-u")) != result.end() || (it = result.find("--username")) != result.end()) + object["username"] = it->second; + + check(request(irccdctl, object)); +} + +/* + * ServerDisconnectCli. + * ------------------------------------------------------------------ + */ + +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 &args) +{ + auto object = nlohmann::json::object({ + { "command", "server-disconnect" } + }); + + if (args.size() > 0) + object["server"] = args[0]; + + check(request(irccdctl, object)); +} + +/* + * ServerInfoCli. + * ------------------------------------------------------------------ + */ + +ServerInfoCli::ServerInfoCli() + : Cli("server-info", + "get server information", + "server-info server", + "Get information about a server.\n\n" + "Example:\n" + "\tirccdctl server-info freenode") +{ +} + +void ServerInfoCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 1) + throw std::invalid_argument("server-info requires 1 argument"); + + auto result = request(irccdctl, { + { "command", "server-info" }, + { "server", args[0] } + }); + + check(result); + + std::cout << std::boolalpha; + std::cout << "Name : " << util::json::pretty(result["name"]) << std::endl; + std::cout << "Host : " << util::json::pretty(result["host"]) << std::endl; + std::cout << "Port : " << util::json::pretty(result["port"]) << std::endl; + std::cout << "Ipv6 : " << util::json::pretty(result["ipv6"]) << std::endl; + std::cout << "SSL : " << util::json::pretty(result["ssl"]) << std::endl; + std::cout << "SSL verified : " << util::json::pretty(result["sslVerify"]) << std::endl; + std::cout << "Channels : "; + + for (const auto &v : result["channels"]) + if (v.is_string()) + std::cout << v.get() << " "; + + std::cout << std::endl; + + std::cout << "Nickname : " << util::json::pretty(result["nickname"]) << std::endl; + std::cout << "User name : " << util::json::pretty(result["username"]) << std::endl; + std::cout << "Real name : " << util::json::pretty(result["realname"]) << std::endl; +} + +/* + * ServerInviteCli. + * ------------------------------------------------------------------ + */ + +ServerInviteCli::ServerInviteCli() + : Cli("server-invite", + "invite someone", + "server-invite server nickname channel", + "Invite the specified target on the channel.\n\n" + "Example:\n" + "\tirccdctl server-invite freenode xorg62 #staff") +{ +} + +void ServerInviteCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 3) + throw std::invalid_argument("server-invite requires 3 arguments"); + + check(request(irccdctl, { + { "command", "server-invite" }, + { "server", args[0] }, + { "target", args[1] }, + { "channel", args[2] } + })); +} + +/* + * ServerJoinCli. + * ------------------------------------------------------------------ + */ + +ServerJoinCli::ServerJoinCli() + : Cli("server-join", + "join a channel", + "server-join server channel [password]", + "Join the specified channel, the password is optional.\n\n" + "Example:\n" + "\tirccdctl server-join freenode #test\n" + "\tirccdctl server-join freenode #private-club secret") +{ +} + +void ServerJoinCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 2) + throw std::invalid_argument("server-join requires at least 2 arguments"); + + auto object = nlohmann::json::object({ + { "server", args[0] }, + { "channel", args[1] } + }); + + if (args.size() == 3) + object["password"] = args[2]; + + check(request(irccdctl, object)); +} + +/* + * ServerKickCli. + * ------------------------------------------------------------------ + */ + +ServerKickCli::ServerKickCli() + : Cli("server-kick", + "kick someone from a channel", + "server-kick server target channel [reason]", + "Kick the specified target from the channel, the reason is optional.\n\n" + "Example:\n" + "\tirccdctl server-kick freenode jean #staff \"Stop flooding\"") +{ +} + +void ServerKickCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 3) + throw std::invalid_argument("server-kick requires at least 3 arguments "); + + auto object = nlohmann::json::object({ + { "server", args[0] }, + { "target", args[1] }, + { "channel", args[2] } + }); + + if (args.size() == 4) + object["reason"] = args[3]; + + check(request(irccdctl, object)); +} + +/* + * ServerListCli. + * ------------------------------------------------------------------ + */ + +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 &) +{ + auto response = request(irccdctl); + + check(response); + + for (const auto &n : response["list"]) + if (n.is_string()) + std::cout << n.get() << std::endl; +} + +/* + * ServerMeCli. + * ------------------------------------------------------------------ + */ + +ServerMeCli::ServerMeCli() + : Cli("server-me", + "send an action emote", + "server-me server target message", + "Send an action emote.\n\n" + "Example:\n" + "\tirccdctl server-me freenode #staff \"going back soon\"") +{ +} + +void ServerMeCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 3) + throw std::runtime_error("server-me requires 3 arguments"); + + check(request(irccdctl, { + { "server", args[0] }, + { "target", args[1] }, + { "message", args[2] } + })); +} + +/* + * ServerMessageCli. + * ------------------------------------------------------------------ + */ + +ServerMessageCli::ServerMessageCli() + : Cli("server-message", + "send a message", + "server-message server target message", + "Send a message to the specified target or channel.\n\n" + "Example:\n" + "\tirccdctl server-message freenode #staff \"Hello from irccd\"") +{ +} + +void ServerMessageCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 3) + throw std::invalid_argument("server-message requires 3 arguments"); + + check(request(irccdctl, { + { "server", args[0] }, + { "target", args[1] }, + { "message", args[2] } + })); +} + +/* + * ServerModeCli. + * ------------------------------------------------------------------ + */ + +ServerModeCli::ServerModeCli() + : Cli("server-mode", + "the the user mode", + "server-mode server mode", + "Set the irccd's user mode.\n\n" + "Example:\n" + "\tirccdctl server-mode +i") +{ +} + +void ServerModeCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 2) + throw std::invalid_argument("server-mode requires 2 arguments"); + + check(request(irccdctl, { + { "server", args[0] }, + { "mode", args[1] } + })); +} + +/* + * ServerNickCli. + * ------------------------------------------------------------------ + */ + +ServerNickCli::ServerNickCli() + : Cli("server-nick", + "change your nickname", + "server-nick server nickname", + "Change irccd's nickname.\n\n" + "Example:\n" + "\tirccdctl server-nick freenode david") +{ +} + +void ServerNickCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 2) + throw std::invalid_argument("server-nick requires 2 arguments"); + + check(request(irccdctl, { + { "server", args[0] }, + { "nickname", args[1] } + })); +} + +/* + * ServerNoticeCli. + * ------------------------------------------------------------------ + */ + +ServerNoticeCli::ServerNoticeCli() + : Cli("server-notice", + "send a private notice", + "server-notice server target message", + "Send a private notice to the specified target.\n\n" + "Example:\n" + "\tirccdctl server-notice freenode jean \"I know you are here.\"") +{ +} + +void ServerNoticeCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 3) + throw std::invalid_argument("server-notice requires 3 arguments"); + + check(request(irccdctl, { + { "server", args[0] }, + { "target", args[1] }, + { "message", args[2] } + })); +} + +/* + * ServerPartCli. + * ------------------------------------------------------------------ + */ + +ServerPartCli::ServerPartCli() + : Cli("server-part", + "leave a channel", + "server-part server channel [reason]", + "Leave the specified channel, the reason is optional.\n\n" + "Not all IRC servers support giving a reason to leave a channel, do not " + "specify it if this is a concern.\n\n" + "Example:\n" + "\tirccdctl server-part freenode #staff" + "\tirccdctl server-part freenode #botwar \"too noisy\"") +{ +} + +void ServerPartCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + if (args.size() < 2) + throw std::invalid_argument("server-part requires at least 2 arguments"); + + auto object = nlohmann::json::object({ + { "server", args[0] }, + { "channel", args[1] } + }); + + if (args.size() >= 3) + object["reason"] = args[2]; + + check(request(irccdctl, object)); +} + +/* + * ServerReconnectCli. + * ------------------------------------------------------------------ + */ + +ServerReconnectCli::ServerReconnectCli() + : Cli("server-reconnect", + "force reconnection of a server", + "server-reconnect [server]", + "Force reconnection of one or all servers.\n\n" + "If server is not specified, all servers will try to reconnect.\n\n" + "Example:\n" + "\tirccdctl server-reconnect\n" + "\tirccdctl server-reconnect wanadoo") +{ +} + +void ServerReconnectCli::exec(Irccdctl &irccdctl, const std::vector &args) +{ + auto object = nlohmann::json::object({ + { "command", "server-reconnect" } + }); + + if (args.size() >= 1) + object["server"] = args[0]; + + check(request(irccdctl, object)); +} + +} // !cli + } // !irccd diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/cli.hpp --- a/irccdctl/cli.hpp Sat Nov 12 22:58:48 2016 +0100 +++ b/irccdctl/cli.hpp Sun Nov 13 09:45:54 2016 +0100 @@ -28,6 +28,14 @@ class Irccdctl; +/* + * Cli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Abstract CLI class. + */ class Cli { protected: std::string m_name; @@ -93,6 +101,471 @@ virtual void exec(Irccdctl &client, const std::vector &args) = 0; }; +namespace cli { + +/* + * PluginConfigCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl plugin-config. + */ +class PluginConfigCli : public Cli { +private: + void set(Irccdctl &, const std::vector &); + void get(Irccdctl &, const std::vector &); + void getall(Irccdctl &, const std::vector &); + +public: + /** + * Default constructor. + */ + PluginConfigCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * PluginInfoCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl plugin-info. + */ +class PluginInfoCli : public Cli { +public: + /** + * Default constructor. + */ + PluginInfoCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * PluginListCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl plugin-list. + */ +class PluginListCli : public Cli { +public: + /** + * Default constructor. + */ + PluginListCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * PluginLoadCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl plugin-load. + */ +class PluginLoadCli : public Cli { +public: + /** + * Default constructor. + */ + PluginLoadCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * PluginReloadCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl plugin-reload. + */ +class PluginReloadCli : public Cli { +public: + PluginReloadCli(); + + /** + * \copydoc Command::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * PluginUnloadCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl plugin-unload. + */ +class PluginUnloadCli : public Cli { +public: + PluginUnloadCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerChannelCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-cmode. + */ +class ServerChannelMode : public Cli { +public: + /** + * Default constructor. + */ + ServerChannelMode(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerChannelNoticeCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-cnotice. + */ +class ServerChannelNoticeCli : public Cli { +public: + /** + * Default constructor. + */ + ServerChannelNoticeCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerConnectCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-connect. + */ +class ServerConnectCli : public Cli { +public: + /** + * Default constructor. + */ + ServerConnectCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerDisconnectCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-disconnect. + */ +class ServerDisconnectCli : public Cli { +public: + /** + * Default constructor. + */ + ServerDisconnectCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerInfoCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-info. + */ +class ServerInfoCli : public Cli { +public: + /** + * Default constructor. + */ + ServerInfoCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerInviteCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-invite. + */ +class ServerInviteCli : public Cli { +public: + /** + * Default constructor. + */ + ServerInviteCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerJoinCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-join. + */ +class ServerJoinCli : public Cli { +public: + /** + * Default constructor. + */ + ServerJoinCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerKickCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-kick. + */ +class ServerKickCli : public Cli { +public: + /** + * Default constructor. + */ + ServerKickCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerListCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-list. + */ +class ServerListCli : public Cli { +public: + /** + * Default constructor. + */ + ServerListCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerMeCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-me. + */ +class ServerMeCli : public Cli { +public: + /** + * Default constructor. + */ + ServerMeCli(); + + /** + * \copydoc Command::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerMessageCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-message. + */ +class ServerMessageCli : public Cli { +public: + /** + * Default constructor. + */ + ServerMessageCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerModeCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-mode. + */ +class ServerModeCli : public Cli { +public: + /** + * Default constructor. + */ + ServerModeCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerNickCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-nick. + */ +class ServerNickCli : public Cli { +public: + /** + * Default constructor. + */ + ServerNickCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerNoticeCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-notice. + */ +class ServerNoticeCli : public Cli { +public: + /** + * Default constructor. + */ + ServerNoticeCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerPartCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-part. + */ +class ServerPartCli : public Cli { +public: + /** + * Default constructor. + */ + ServerPartCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +/* + * ServerReconnectCli. + * ------------------------------------------------------------------ + */ + +/** + * \brief Implementation of irccdctl server-reconnect. + */ +class ServerReconnectCli : public Cli { +public: + /** + * Default constructor. + */ + ServerReconnectCli(); + + /** + * \copydoc Cli::exec + */ + void exec(Irccdctl &irccdctl, const std::vector &args) override; +}; + +} // !cli + } // !irccd #endif // !IRCCD_CLI_HPP diff -r 4665fffff6f2 -r 006452e4a997 irccdctl/main.cpp --- a/irccdctl/main.cpp Sat Nov 12 22:58:48 2016 +0100 +++ b/irccdctl/main.cpp Sun Nov 13 09:45:54 2016 +0100 @@ -18,7 +18,8 @@ #include "client.hpp" #include "irccdctl.hpp" - +#include "cli.hpp" +#if 0 #include "cli-plugin-config.hpp" #include "cli-plugin-reload.hpp" #include "cli-plugin-unload.hpp" @@ -38,6 +39,7 @@ #include "cli-server-notice.hpp" #include "cli-server-part.hpp" #include "cli-server-reconnect.hpp" +#endif using namespace irccd;